From 9e6c7794bef00ffabdb693ea32bf048a446af040 Mon Sep 17 00:00:00 2001 From: sjuarezgx Date: Sun, 24 Sep 2023 20:07:19 -0300 Subject: [PATCH] Implementation for NET to use Microsoft.Extensions.Logging API. Add impl for Application Insights logging. --- dotnet/DotNetStandardClasses.sln | 10 - .../DynService/Cosmos/CosmosDBConnection.cs | 3 +- .../DynService/Cosmos/CosmosDBDataReader.cs | 3 +- .../Cosmos/CosmosDBRequestWrapper.cs | 3 +- .../GxClasses.Web/Middleware/GXRouting.cs | 2 +- .../Middleware/HandlerFactory.cs | 2 +- .../Notifications/WebSocket/WSHandler.cs | 2 +- .../GxClasses/Domain/GXXmlReadWrite.cs | 14 +- .../src/dotnetcore/GxClasses/GxClasses.csproj | 2 +- .../GxClasses/Helpers/GXGeographyCore.cs | 2 +- .../AzureAppInsightsLogProvider.cs | 13 +- .../Services/LogService/GXLogService.cs | 39 +- .../OpenTelemetry/OpenTelemetryService.cs | 5 +- .../GxClasses/Services/ServiceSettings.cs | 8 +- .../Services/Session/GXSessionFactory.cs | 7 +- .../dotnetcore/GxNetCoreStartup/Startup.cs | 22 +- .../GeneXus.Log.Azure.AzureAppInsights.csproj | 23 - .../Messaging/GXAmazonSQS/AWSQueue.cs | 2 +- .../GXAzureEventGrid/AzureEventGrid.cs | 2 +- .../Messaging/GXAzureQueue/AzureQueue.cs | 4 +- .../GXAzureServiceBus/AzureServiceBus.cs | 2 +- .../GXEventRouter/EventRouterBase.cs | 2 +- .../GXEventRouter/EventRouterProvider.cs | 2 +- .../GXEventRouter/EventRouterProviderBase.cs | 4 +- .../GXMessageBroker/MessageBrokerBase.cs | 2 +- .../GXMessageBroker/MessageBrokerProvider.cs | 2 +- .../Messaging/GXMessageBroker/MessageQueue.cs | 4 +- .../GXMessageBroker/ServiceSettings.cs | 2 +- .../Messaging/GXQueue/MessageQueueProvider.cs | 2 +- .../Providers/Messaging/GXQueue/QueueBase.cs | 2 +- .../Messaging/GXQueue/SimpleMessageQueue.cs | 4 +- .../AzureAppInsights.cs | 6 +- .../LightstepProvider.cs | 4 +- .../GxClasses.Win/Process/CommandLine.cs | 3 +- .../Configuration/ExternalStorage.cs | 7 +- .../Configuration/LogConfiguration.cs | 4 +- .../GxClasses/Core/GXApplication.cs | 122 ++-- .../dotnetframework/GxClasses/Core/GXUtils.cs | 2 +- .../GxClasses/Core/GXUtilsCommon.cs | 18 +- .../GxClasses/Core/Web/HttpAjaxContext.cs | 2 +- .../GxClasses/Core/gxconfig.cs | 80 ++- .../Cryptography/GXAsymmetricEncryption.cs | 16 +- .../GxClasses/Cryptography/GXCertificate.cs | 7 +- .../Cryptography/GXSymmetricEncryption.cs | 18 +- .../GxClasses/Data/GXDataADO.cs | 10 +- .../GxClasses/Data/GXDataCommon.cs | 30 +- .../GxClasses/Data/GXDataDb2.cs | 5 +- .../GxClasses/Data/GXDataDb2400.cs | 8 +- .../GxClasses/Data/GXDataHana.cs | 6 +- .../GxClasses/Data/GXDataInformix.cs | 6 +- .../GxClasses/Data/GXDataMysqlConnector.cs | 11 +- .../GxClasses/Data/GXDataMysqlDriverCS.cs | 7 +- .../GxClasses/Data/GXDataNTier.cs | 5 +- .../GxClasses/Data/GXDataNTierADO.cs | 6 +- .../GxClasses/Data/GXDataNTierService.cs | 7 +- .../GxClasses/Data/GXDataOracle.cs | 21 +- .../GxClasses/Data/GXDataPostgreSQL.cs | 4 +- .../GxClasses/Data/GXDataSqlite.cs | 5 +- .../GxClasses/Diagnostics/GXDebugManager.cs | 2 +- .../GxClasses/Diagnostics/Log.cs | 69 ++- .../GxClasses/Dialog/IProcess.cs | 3 +- .../GxClasses/Domain/ExpressionEvaluator.cs | 2 +- .../GxClasses/Domain/GXFileIO.cs | 9 +- .../GxClasses/Domain/GXGeolocation.cs | 2 +- .../GxClasses/Domain/GXLDAP.cs | 2 +- .../GxClasses/Domain/GXXmlReadWrite.cs | 2 +- .../GxClasses/Domain/GxCollections.cs | 6 +- .../GxClasses/Domain/GxGenericCollections.cs | 4 +- .../GxClasses/Domain/GxHttpClient.cs | 2 +- .../GxClasses/Domain/GxMessaging.cs | 5 +- .../GxClasses/Domain/GxSession.cs | 2 +- .../GxClasses/Domain/SD/SDApis.cs | 4 +- .../GxClasses/Helpers/GXFileWatcher.cs | 2 +- .../GxClasses/Helpers/GXLogging.cs | 577 +++++++++++++----- .../GxClasses/Helpers/GXMetadata.cs | 2 +- .../GxClasses/Helpers/GXRes.cs | 2 +- .../GxClasses/Helpers/GXRestUtils.cs | 2 +- .../GxClasses/Helpers/GXUtilsGeospatial.cs | 4 +- .../GxClasses/Helpers/HttpHelper.cs | 2 +- .../GxClasses/Helpers/JSONHelper.cs | 2 +- .../GxClasses/Helpers/ThemeHelper.cs | 2 +- .../GxClasses/Management/GXManagement.cs | 13 +- .../GxClasses/Management/GXPerformance.cs | 4 +- .../GxClasses/Middleware/GXHttp.cs | 5 +- .../GxClasses/Middleware/GXHttpModules.cs | 4 +- .../GxClasses/Middleware/GXHttpServices.cs | 7 +- .../GxClasses/Middleware/HandlerFactory.cs | 2 +- .../GxClasses/Model/GXBaseObject.cs | 3 +- .../GxClasses/Model/GXSilentTrn.cs | 2 +- .../GxClasses/Model/GxMockProvider.cs | 2 +- .../dotnetframework/GxClasses/Model/gxproc.cs | 2 +- .../WebSocket/GXWebSocketFactory.cs | 5 +- .../GxClasses/Printer/GxPrinter.cs | 2 +- .../GxClasses/Reorg/GXReorg.cs | 2 +- .../GxClasses/Security/GxSecurityProvider.cs | 2 +- .../GxClasses/Security/WebSecurity.cs | 18 +- .../GxClasses/Services/Caching/GxCache.cs | 14 +- .../GxClasses/Services/GXRestServices.cs | 5 +- .../GxClasses/Services/GxRestWrapper.cs | 2 +- .../Services/Storage/ExternalProviderBase.cs | 10 +- .../GxClasses/Services/Storage/GXServices.cs | 6 +- .../GxClasses/View/GXWebControls.cs | 2 +- .../GXDataInitialization.cs | 2 +- .../dotnetframework/GxExcel/GxExcelEPPlus.cs | 8 +- .../src/dotnetframework/GxExcel/GxExcelI.cs | 12 +- .../dotnetframework/GxExcel/GxExcelLite.cs | 4 +- .../GxMail/Exchange/ExchangeSession.cs | 5 +- .../GxMail/Exchange/Service.cs | 6 +- .../GxMail/Exchange/TraceListener.cs | 12 +- .../dotnetframework/GxMail/GXMailSession.cs | 2 +- .../dotnetframework/GxMail/GXPOP3Session.cs | 3 +- .../dotnetframework/GxMail/GXSMTPSession.cs | 5 +- .../src/dotnetframework/GxMail/MAPISession.cs | 3 +- .../src/dotnetframework/GxMail/MailMessage.cs | 2 +- .../GxMail/Mentalis/RFC822EndReader.cs | 2 +- .../dotnetframework/GxMail/OutlookSession.cs | 2 +- .../src/dotnetframework/GxMail/POP3Session.cs | 3 +- .../GxMail/POP3SessionOpenPop.cs | 4 +- .../src/dotnetframework/GxMail/Pop3MailKit.cs | 3 +- .../dotnetframework/GxMail/Pop3SessionBase.cs | 14 +- .../dotnetframework/GxMail/SMTP/SmtpHelper.cs | 2 +- .../dotnetframework/GxMail/SMTPMailClient.cs | 2 +- .../src/dotnetframework/GxMail/SMTPMailKit.cs | 2 +- .../src/dotnetframework/GxMail/SMTPSession.cs | 2 +- .../GxOffice/ExcelSpreadsheetGXWrapper.cs | 10 +- .../GxOffice/poi/xssf/ExcelCells.cs | 5 +- .../GxOffice/poi/xssf/ExcelSpreadsheet.cs | 7 +- .../GxPdfReportsCS/PDFReportItext.cs | 12 +- .../GxPdfReportsCS/PdfReportInterface.cs | 3 +- .../GxSearch/DocumentHandler.cs | 6 +- .../src/dotnetframework/GxSearch/Indexer.cs | 2 +- .../src/dotnetframework/GxSearch/Searcher.cs | 2 +- .../src/dotnetframework/GxSearch/Settings.cs | 2 +- .../dotnetframework/GxSearch/SpellChecker.cs | 2 +- .../dotnetframework/GxWebSocket/WSHandler.cs | 6 +- .../StoreManager/Store/StoreManager.cs | 3 +- .../Cache/GxMemcached/GxMemcached.cs | 2 +- .../Providers/Cache/GxRedis/GxRedis.cs | 3 +- .../HttpHandler/GXHttpAzureContextAccessor.cs | 2 +- 139 files changed, 954 insertions(+), 650 deletions(-) rename dotnet/src/dotnetcore/{Providers/Logging/GeneXus.Log.Azure.AzureAppInsights => GxClasses/Services/LogService/AzureAppInsights}/AzureAppInsightsLogProvider.cs (82%) delete mode 100644 dotnet/src/dotnetcore/Providers/Logging/GeneXus.Log.Azure.AzureAppInsights/GeneXus.Log.Azure.AzureAppInsights.csproj diff --git a/dotnet/DotNetStandardClasses.sln b/dotnet/DotNetStandardClasses.sln index e6d5a85c4..10e02e893 100644 --- a/dotnet/DotNetStandardClasses.sln +++ b/dotnet/DotNetStandardClasses.sln @@ -252,10 +252,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GXAzureEventGrid", "src\dot EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetCoreAttackMitigationTest", "test\DotNetCoreAttackMitigationTest\DotNetCoreAttackMitigationTest.csproj", "{2D615969-53E2-4B77-9A9A-75C33865CF76}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gxlogging", "gxlogging", "{AA04A8A9-3CBD-431D-9711-C4D481E4A1E5}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeneXus.Log.Azure.AzureAppInsights", "src\dotnetcore\Providers\Logging\GeneXus.Log.Azure.AzureAppInsights\GeneXus.Log.Azure.AzureAppInsights.csproj", "{6B28F942-D355-44A2-9C5D-92AF2D256A0D}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -610,10 +606,6 @@ Global {2D615969-53E2-4B77-9A9A-75C33865CF76}.Debug|Any CPU.Build.0 = Debug|Any CPU {2D615969-53E2-4B77-9A9A-75C33865CF76}.Release|Any CPU.ActiveCfg = Release|Any CPU {2D615969-53E2-4B77-9A9A-75C33865CF76}.Release|Any CPU.Build.0 = Release|Any CPU - {6B28F942-D355-44A2-9C5D-92AF2D256A0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6B28F942-D355-44A2-9C5D-92AF2D256A0D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6B28F942-D355-44A2-9C5D-92AF2D256A0D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6B28F942-D355-44A2-9C5D-92AF2D256A0D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -733,8 +725,6 @@ Global {5BBC75F0-E51A-4EBD-A628-92498D319B1D} = {4C43F2DA-59E5-46F5-B691-195449498555} {7250CDB1-95C4-4822-B01B-3CBD73324CC9} = {30159B0F-BE61-4DB7-AC02-02851426BE4B} {2D615969-53E2-4B77-9A9A-75C33865CF76} = {1D6F1776-FF4B-46C2-9B3D-BC46CCF049DC} - {AA04A8A9-3CBD-431D-9711-C4D481E4A1E5} = {2261B65E-3757-4E5B-9DCD-EAE8D1E236A3} - {6B28F942-D355-44A2-9C5D-92AF2D256A0D} = {AA04A8A9-3CBD-431D-9711-C4D481E4A1E5} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E18684C9-7D76-45CD-BF24-E3944B7F174C} diff --git a/dotnet/src/dotnetcore/DynService/Cosmos/CosmosDBConnection.cs b/dotnet/src/dotnetcore/DynService/Cosmos/CosmosDBConnection.cs index 756d8c365..2d64302a9 100644 --- a/dotnet/src/dotnetcore/DynService/Cosmos/CosmosDBConnection.cs +++ b/dotnet/src/dotnetcore/DynService/Cosmos/CosmosDBConnection.cs @@ -12,7 +12,6 @@ using GeneXus.Cache; using GeneXus.Data.Cosmos; using GeneXus.Data.NTier.CosmosDB; -using log4net; using Microsoft.Azure.Cosmos; namespace GeneXus.Data.NTier @@ -65,7 +64,7 @@ public class CosmosDBConnection : ServiceConnection //Options not supported by the spec yet //private const string DISTINCT = "DISTINCT"; - static readonly ILog logger = log4net.LogManager.GetLogger(typeof(CosmosDBConnection)); + static readonly IGXLogger logger = GXLoggerFactory.GetLogger(); public override string ConnectionString { get diff --git a/dotnet/src/dotnetcore/DynService/Cosmos/CosmosDBDataReader.cs b/dotnet/src/dotnetcore/DynService/Cosmos/CosmosDBDataReader.cs index f74528139..45ee1b70a 100644 --- a/dotnet/src/dotnetcore/DynService/Cosmos/CosmosDBDataReader.cs +++ b/dotnet/src/dotnetcore/DynService/Cosmos/CosmosDBDataReader.cs @@ -9,7 +9,6 @@ using GeneXus.Cache; using GeneXus.Data.NTier; using GeneXus.Data.NTier.CosmosDB; -using log4net; using Microsoft.Azure.Cosmos; using Newtonsoft.Json; @@ -27,7 +26,7 @@ public class CosmosDBDataReader : IDataReader private int ItemCount; private List> Items = null; - static readonly ILog logger = log4net.LogManager.GetLogger(typeof(CosmosDBDataReader)); + static readonly IGXLogger logger = GXLoggerFactory.GetLogger(); private void CheckCurrentPosition() { if (m_currentEntry == null) diff --git a/dotnet/src/dotnetcore/DynService/Cosmos/CosmosDBRequestWrapper.cs b/dotnet/src/dotnetcore/DynService/Cosmos/CosmosDBRequestWrapper.cs index aaa3a62c2..faf6b9f97 100644 --- a/dotnet/src/dotnetcore/DynService/Cosmos/CosmosDBRequestWrapper.cs +++ b/dotnet/src/dotnetcore/DynService/Cosmos/CosmosDBRequestWrapper.cs @@ -3,7 +3,6 @@ using System.IO; using System.Threading.Tasks; using GeneXus.Data.Cosmos; -using log4net; using Microsoft.Azure.Cosmos; using Newtonsoft.Json; @@ -14,7 +13,7 @@ public class RequestWrapper private readonly Container m_container; private readonly CosmosClient m_cosmosClient; private readonly QueryDefinition m_queryDefinition; - static readonly ILog logger = log4net.LogManager.GetLogger(typeof(RequestWrapper)); + static readonly IGXLogger logger = GXLoggerFactory.GetLogger(); public string idValue { get; set; } public object partitionKeyValue { get; set; } public bool queryByPK { get; set; } diff --git a/dotnet/src/dotnetcore/GxClasses.Web/Middleware/GXRouting.cs b/dotnet/src/dotnetcore/GxClasses.Web/Middleware/GXRouting.cs index 25573f464..f6d88c57c 100644 --- a/dotnet/src/dotnetcore/GxClasses.Web/Middleware/GXRouting.cs +++ b/dotnet/src/dotnetcore/GxClasses.Web/Middleware/GXRouting.cs @@ -28,7 +28,7 @@ namespace GxClasses.Web.Middleware internal class GXRouting : IGXRouting { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(IGXRouting)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public static string VirtualPath = string.Empty; public static string LocalPath = Directory.GetCurrentDirectory(); diff --git a/dotnet/src/dotnetcore/GxClasses.Web/Middleware/HandlerFactory.cs b/dotnet/src/dotnetcore/GxClasses.Web/Middleware/HandlerFactory.cs index 549b6ba9e..acb44ac7a 100644 --- a/dotnet/src/dotnetcore/GxClasses.Web/Middleware/HandlerFactory.cs +++ b/dotnet/src/dotnetcore/GxClasses.Web/Middleware/HandlerFactory.cs @@ -32,7 +32,7 @@ public class BaseUrls public class HandlerFactory { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.HttpHandlerFactory.HandlerFactory)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private string _basePath; static Dictionary _aspxObjects = new Dictionary(){ {"gxoauthlogout",typeof(GXOAuthLogout)}, diff --git a/dotnet/src/dotnetcore/GxClasses.Web/Notifications/WebSocket/WSHandler.cs b/dotnet/src/dotnetcore/GxClasses.Web/Notifications/WebSocket/WSHandler.cs index ae0051f63..92f15fc43 100644 --- a/dotnet/src/dotnetcore/GxClasses.Web/Notifications/WebSocket/WSHandler.cs +++ b/dotnet/src/dotnetcore/GxClasses.Web/Notifications/WebSocket/WSHandler.cs @@ -18,7 +18,7 @@ namespace GeneXus.Http.WebSocket { public class WSHandler: WebSocketHandler, IGXWebSocketAsync { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(WSHandler)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private const string GX_NOTIFICATIONINFO_NAME = "GeneXus.Core.genexus.server.SdtNotificationInfo"; protected static WebSocketConnectionManager WebSocketConnectionManager = new WebSocketConnectionManager(); diff --git a/dotnet/src/dotnetcore/GxClasses/Domain/GXXmlReadWrite.cs b/dotnet/src/dotnetcore/GxClasses/Domain/GXXmlReadWrite.cs index 71b13de71..aa04926c8 100644 --- a/dotnet/src/dotnetcore/GxClasses/Domain/GXXmlReadWrite.cs +++ b/dotnet/src/dotnetcore/GxClasses/Domain/GXXmlReadWrite.cs @@ -1,19 +1,17 @@ using System; -using System.Xml; using System.Collections; using System.Collections.Specialized; -using System.Text; -using System.Net; using System.IO; +using System.Net; +using System.Text; +using System.Xml; using System.Xml.Schema; +using System.Xml.XPath; +using System.Xml.Xsl; using GeneXus.Application; using GeneXus.Http.Client; using GeneXus.Http.Server; using GeneXus.Utils; -using log4net; - -using System.Xml.Xsl; -using System.Xml.XPath; namespace GeneXus.XML { @@ -1887,7 +1885,7 @@ public void Dispose() public class GXXMLWriter: IDisposable { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GXXMLWriter)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private XmlTextWriter writer; private short errorCode; diff --git a/dotnet/src/dotnetcore/GxClasses/GxClasses.csproj b/dotnet/src/dotnetcore/GxClasses/GxClasses.csproj index 25f3782a1..8c71be5d2 100644 --- a/dotnet/src/dotnetcore/GxClasses/GxClasses.csproj +++ b/dotnet/src/dotnetcore/GxClasses/GxClasses.csproj @@ -55,7 +55,6 @@ - @@ -78,6 +77,7 @@ + diff --git a/dotnet/src/dotnetcore/GxClasses/Helpers/GXGeographyCore.cs b/dotnet/src/dotnetcore/GxClasses/Helpers/GXGeographyCore.cs index f4b03d19a..e33b0802d 100644 --- a/dotnet/src/dotnetcore/GxClasses/Helpers/GXGeographyCore.cs +++ b/dotnet/src/dotnetcore/GxClasses/Helpers/GXGeographyCore.cs @@ -204,7 +204,7 @@ internal static object STRingN(object instance, int i) [DataContract] public class Geospatial : IGeographicNative { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Utils.Geospatial)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); internal const string EMPTY_GEOMETRY = "GEOMETRYCOLLECTION EMPTY"; const string EMPTY_GEOGRAPHY = "GEOGRAPHY EMPTY"; diff --git a/dotnet/src/dotnetcore/Providers/Logging/GeneXus.Log.Azure.AzureAppInsights/AzureAppInsightsLogProvider.cs b/dotnet/src/dotnetcore/GxClasses/Services/LogService/AzureAppInsights/AzureAppInsightsLogProvider.cs similarity index 82% rename from dotnet/src/dotnetcore/Providers/Logging/GeneXus.Log.Azure.AzureAppInsights/AzureAppInsightsLogProvider.cs rename to dotnet/src/dotnetcore/GxClasses/Services/LogService/AzureAppInsights/AzureAppInsightsLogProvider.cs index 7bc3de514..a989b4843 100644 --- a/dotnet/src/dotnetcore/Providers/Logging/GeneXus.Log.Azure.AzureAppInsights/AzureAppInsightsLogProvider.cs +++ b/dotnet/src/dotnetcore/GxClasses/Services/LogService/AzureAppInsights/AzureAppInsightsLogProvider.cs @@ -1,24 +1,23 @@ using System; -using GeneXus.Services; -using GeneXus.Services.Log; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Configuration; -namespace GeneXus.Log.Azure +namespace GeneXus.Services.Log { - public class AzureAppInsightsLogProvider : IGXLogProvider + public class AzureAppInsightsLogProvider : ILoggerFactory { private static string APPLICATIONINSIGHTS_CONNECTION_STRING = "APPLICATIONINSIGHTS_CONNECTION_STRING"; public static ILoggerFactory loggerFactory; - - public AzureAppInsightsLogProvider(GXService s) { } - public ILoggerFactory GetLoggerFactory() + + public static ILoggerFactory GetLoggerFactory() { string appInsightsConnection = Environment.GetEnvironmentVariable(APPLICATIONINSIGHTS_CONNECTION_STRING); if (appInsightsConnection != null) { loggerFactory = LoggerFactory.Create(builder => builder.AddApplicationInsights( configureTelemetryConfiguration: (config) => + //config.SetAzureTokenCredential config.ConnectionString = appInsightsConnection, configureApplicationInsightsLoggerOptions: (options) => { } ) diff --git a/dotnet/src/dotnetcore/GxClasses/Services/LogService/GXLogService.cs b/dotnet/src/dotnetcore/GxClasses/Services/LogService/GXLogService.cs index 8db922e1b..ddbbda4f0 100644 --- a/dotnet/src/dotnetcore/GxClasses/Services/LogService/GXLogService.cs +++ b/dotnet/src/dotnetcore/GxClasses/Services/LogService/GXLogService.cs @@ -1,46 +1,25 @@ using System; -using GeneXus.Application; -using GxClasses.Helpers; +using GeneXus.Configuration; using Microsoft.Extensions.Logging; namespace GeneXus.Services.Log { - public interface IGXLogProvider : ILoggerFactory - { - ILoggerFactory GetLoggerFactory(); - } - public static class GXLogService { - private static string LOG_SERVICE = "Log"; - + private static string AZURE_APPLICATION_INSIGHTS_LOG = "AZUREAPPLICATIONINSIGHTS"; + private const string LOG_OUTPUT_ENVVAR = "GX_LOG_OUTPUT"; public static ILoggerFactory GetLogFactory() { - IGXLogProvider gxLogProvider = null; - GXService providerService = GXServices.Instance?.Get(LOG_SERVICE); + string logoutput = Environment.GetEnvironmentVariable(LOG_OUTPUT_ENVVAR); + if (logoutput == null) { - if (providerService != null) - { - try - { -#if !NETCORE - Type type = Type.GetType(providerService.ClassName, true, true); -#else - Type type = AssemblyLoader.GetType(providerService.ClassName); -#endif - gxLogProvider = (IGXLogProvider)Activator.CreateInstance(type, new object[] { providerService }); - return gxLogProvider.GetLoggerFactory(); - } - catch (Exception e) - { - throw e; - } + Config.GetValueOf("LOG_OUTPUT", out string logProvider); + logoutput = logProvider; } + if (logoutput == AZURE_APPLICATION_INSIGHTS_LOG) + return GeneXus.Services.Log.AzureAppInsightsLogProvider.GetLoggerFactory(); else - { return null; - } - } } } diff --git a/dotnet/src/dotnetcore/GxClasses/Services/OpenTelemetry/OpenTelemetryService.cs b/dotnet/src/dotnetcore/GxClasses/Services/OpenTelemetry/OpenTelemetryService.cs index 125f05ff5..9e17ad7ce 100644 --- a/dotnet/src/dotnetcore/GxClasses/Services/OpenTelemetry/OpenTelemetryService.cs +++ b/dotnet/src/dotnetcore/GxClasses/Services/OpenTelemetry/OpenTelemetryService.cs @@ -11,7 +11,8 @@ public interface IOpenTelemetryProvider public static class OpenTelemetryService { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(OpenTelemetryService)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); + private static string OPENTELEMETRY_SERVICE = "Observability"; public static string GX_ACTIVITY_SOURCE_NAME = "GeneXus.Tracing"; @@ -49,7 +50,7 @@ internal static void Setup(Microsoft.Extensions.DependencyInjection.IServiceColl bool started = provider.InstrumentAspNetCoreApplication(services); if (started) { - log.Info("OpenTelemetry instrumentation started"); + GXLogging.Info(log, "OpenTelemetry instrumentation started"); } } } diff --git a/dotnet/src/dotnetcore/GxClasses/Services/ServiceSettings.cs b/dotnet/src/dotnetcore/GxClasses/Services/ServiceSettings.cs index 2249548f0..05c398a7e 100644 --- a/dotnet/src/dotnetcore/GxClasses/Services/ServiceSettings.cs +++ b/dotnet/src/dotnetcore/GxClasses/Services/ServiceSettings.cs @@ -6,7 +6,7 @@ namespace GeneXus.Services.Common { public class ServiceSettingsReader { - static readonly ILog logger = log4net.LogManager.GetLogger(typeof(ServiceSettingsReader)); + static readonly IGXLogger logger = GXLoggerFactory.GetLogger(); internal GXService service; public string serviceNameResolver { get; } @@ -25,7 +25,7 @@ public string GetEncryptedPropertyValue(string propertyName) if (value == null) { String errorMessage = String.Format($"Service configuration error - Property name {ResolvePropertyName(propertyName)} must be defined"); - logger.Fatal(errorMessage); + GXLogging.Critical(logger, errorMessage); throw new Exception(errorMessage); } return value; @@ -45,7 +45,7 @@ public string GetEncryptedPropertyValue(string propertyName, string defaultValue } catch (Exception) { - logger.Warn($"Could not decrypt property name: {ResolvePropertyName(propertyName)}"); + GXLogging.Warn(logger, $"Could not decrypt property name: {ResolvePropertyName(propertyName)}"); } } return value; @@ -57,7 +57,7 @@ public string GetPropertyValue(string propertyName) if (value == null) { String errorMessage = String.Format($"Service configuration error - Property name {ResolvePropertyName(propertyName)} must be defined"); - logger.Fatal(errorMessage); + GXLogging.Critical(logger, errorMessage); throw new Exception(errorMessage); } return value; diff --git a/dotnet/src/dotnetcore/GxClasses/Services/Session/GXSessionFactory.cs b/dotnet/src/dotnetcore/GxClasses/Services/Session/GXSessionFactory.cs index 51e578ce0..022d21373 100644 --- a/dotnet/src/dotnetcore/GxClasses/Services/Session/GXSessionFactory.cs +++ b/dotnet/src/dotnetcore/GxClasses/Services/Session/GXSessionFactory.cs @@ -11,7 +11,8 @@ namespace GeneXus.Services { public class GXSessionServiceFactory { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GXSessionServiceFactory)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + static string REDIS = "REDIS"; static string DATABASE = "DATABASE"; public static ISessionService GetProvider() @@ -58,7 +59,7 @@ public static ISessionService GetProvider() } public class GxRedisSession : ISessionService { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GxRedisSession)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); internal static string SESSION_ADDRESS = "SESSION_PROVIDER_ADDRESS"; internal static string SESSION_INSTANCE = "SESSION_PROVIDER_INSTANCE_NAME"; internal static string SESSION_PASSWORD = "SESSION_PROVIDER_PASSWORD"; @@ -108,7 +109,7 @@ public GxRedisSession(string host, string password, string instanceName, int ses } public class GxDatabaseSession : ISessionService { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GxDatabaseSession)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); internal static string SESSION_ADDRESS = "SESSION_PROVIDER_ADDRESS"; internal static string SESSION_PASSWORD = "SESSION_PROVIDER_PASSWORD"; internal static string SESSION_SCHEMA = "SESSION_PROVIDER_SCHEMA"; diff --git a/dotnet/src/dotnetcore/GxNetCoreStartup/Startup.cs b/dotnet/src/dotnetcore/GxNetCoreStartup/Startup.cs index 3495ef6c2..223901d1b 100644 --- a/dotnet/src/dotnetcore/GxNetCoreStartup/Startup.cs +++ b/dotnet/src/dotnetcore/GxNetCoreStartup/Startup.cs @@ -30,6 +30,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.Logging; +using NUglify.JavaScript.Syntax; using StackExchange.Redis; @@ -124,9 +125,9 @@ public static IApplicationBuilder MapWebSocketManager(this IApplicationBuilder a } public class Startup - { - - static readonly ILog log = log4net.LogManager.GetLogger(typeof(Startup)); + { + public static bool IsHttpContext = InitializeHttpContext(); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); const long DEFAULT_MAX_FILE_UPLOAD_SIZE_BYTES = 528000000; public static string VirtualPath = string.Empty; public static string LocalPath = Directory.GetCurrentDirectory(); @@ -150,6 +151,11 @@ public class Startup private GXRouting gxRouting; + static bool InitializeHttpContext() + { + GxContext.IsHttpContext = true; + return true; + } public Startup(IConfiguration configuration, IHostingEnvironment env) { Config.ConfigRoot = configuration; @@ -299,7 +305,11 @@ private void ConfigureSessionService(IServiceCollection services, ISessionServic public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env, ILoggerFactory loggerFactory) { string baseVirtualPath = string.IsNullOrEmpty(VirtualPath) ? VirtualPath : $"/{VirtualPath}"; - LogConfiguration.SetupLog4Net(); + Config.GetValueOf("LOG_OUTPUT", out string logProvider); + if (logProvider == "ASPNetTraceAppender" || logProvider == "ConsoleAppender" || logProvider == "EventLogAppender" || logProvider == "RollingFile") + { + LogConfiguration.SetupLog4Net(); + } var provider = new FileExtensionContentTypeProvider(); //mappings provider.Mappings[".json"] = "application/json"; @@ -505,7 +515,7 @@ bool IsAspx(HttpContext context, string basePath) public class CustomExceptionHandlerMiddleware { const string InvalidCSRFToken = "InvalidCSRFToken"; - static readonly ILog log = log4net.LogManager.GetLogger(typeof(CustomExceptionHandlerMiddleware)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public async Task Invoke(HttpContext httpContext) { string httpReasonPhrase=string.Empty; @@ -589,7 +599,7 @@ public IActionResult Index() } public class ValidateAntiForgeryTokenMiddleware { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(ValidateAntiForgeryTokenMiddleware)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private readonly RequestDelegate _next; private readonly IAntiforgery _antiforgery; diff --git a/dotnet/src/dotnetcore/Providers/Logging/GeneXus.Log.Azure.AzureAppInsights/GeneXus.Log.Azure.AzureAppInsights.csproj b/dotnet/src/dotnetcore/Providers/Logging/GeneXus.Log.Azure.AzureAppInsights/GeneXus.Log.Azure.AzureAppInsights.csproj deleted file mode 100644 index 06128b5db..000000000 --- a/dotnet/src/dotnetcore/Providers/Logging/GeneXus.Log.Azure.AzureAppInsights/GeneXus.Log.Azure.AzureAppInsights.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - net6.0 - NETCORE; - Properties - false - GeneXus.Log.Azure.AzureAppInsights - Azure Application Insights Log GeneXus - GeneXus.Log.Azure.AzureAppInsights - - - - - - - - - - - - - diff --git a/dotnet/src/dotnetcore/Providers/Messaging/GXAmazonSQS/AWSQueue.cs b/dotnet/src/dotnetcore/Providers/Messaging/GXAmazonSQS/AWSQueue.cs index 1e76f3b24..071ea69fc 100644 --- a/dotnet/src/dotnetcore/Providers/Messaging/GXAmazonSQS/AWSQueue.cs +++ b/dotnet/src/dotnetcore/Providers/Messaging/GXAmazonSQS/AWSQueue.cs @@ -31,7 +31,7 @@ public class AWSQueue : QueueBase, IQueue public const string MESSSAGE_GROUP_ID = "MessageGroupId"; public const string MESSSAGE_DEDUPLICATION_ID = "MessageDeduplicationId"; - static readonly ILog logger = log4net.LogManager.GetLogger(typeof(AWSQueue)); + static readonly IGXLogger logger = GXLoggerFactory.GetLogger(); public AWSQueue() : this(null) { diff --git a/dotnet/src/dotnetcore/Providers/Messaging/GXAzureEventGrid/AzureEventGrid.cs b/dotnet/src/dotnetcore/Providers/Messaging/GXAzureEventGrid/AzureEventGrid.cs index 921497aac..f69a69466 100644 --- a/dotnet/src/dotnetcore/Providers/Messaging/GXAzureEventGrid/AzureEventGrid.cs +++ b/dotnet/src/dotnetcore/Providers/Messaging/GXAzureEventGrid/AzureEventGrid.cs @@ -20,7 +20,7 @@ public class AzureEventGrid : EventRouterBase, IEventRouter private EventGridPublisherClient _client; private string _endpoint; private string _accessKey; - static readonly ILog logger = LogManager.GetLogger(typeof(AzureEventGrid)); + static readonly IGXLogger logger = GXLoggerFactory.GetLogger(); public AzureEventGrid() : this(null) { } diff --git a/dotnet/src/dotnetcore/Providers/Messaging/GXAzureQueue/AzureQueue.cs b/dotnet/src/dotnetcore/Providers/Messaging/GXAzureQueue/AzureQueue.cs index 0435a7a55..519dce15a 100644 --- a/dotnet/src/dotnetcore/Providers/Messaging/GXAzureQueue/AzureQueue.cs +++ b/dotnet/src/dotnetcore/Providers/Messaging/GXAzureQueue/AzureQueue.cs @@ -8,6 +8,7 @@ using GeneXus.Services; using GeneXus.Utils; using log4net; +using Microsoft.Extensions.Logging; namespace GeneXus.Messaging.Queue { @@ -15,7 +16,8 @@ public class AzureQueue : QueueBase, IQueue { public static string Name = "AZUREQUEUE"; - static readonly ILog logger = LogManager.GetLogger(typeof(AzureQueue)); + static readonly IGXLogger logger = GXLoggerFactory.GetLogger(); + QueueClient _queueClient { get; set; } private string _queueName { get; set; } private string _connectionString { get; set; } diff --git a/dotnet/src/dotnetcore/Providers/Messaging/GXAzureServiceBus/AzureServiceBus.cs b/dotnet/src/dotnetcore/Providers/Messaging/GXAzureServiceBus/AzureServiceBus.cs index c44390a41..92e06e744 100644 --- a/dotnet/src/dotnetcore/Providers/Messaging/GXAzureServiceBus/AzureServiceBus.cs +++ b/dotnet/src/dotnetcore/Providers/Messaging/GXAzureServiceBus/AzureServiceBus.cs @@ -18,7 +18,7 @@ public class AzureServiceBus : MessageBrokerBase, IMessageBroker private const int MAX_MESSAGES_DEFAULT = 10; private const short LOCK_DURATION = 5; public static string Name = "AZURESB"; - static readonly ILog logger = LogManager.GetLogger(typeof(AzureServiceBus)); + static readonly IGXLogger logger = GXLoggerFactory.GetLogger(); private ConcurrentDictionary> m_messages = new ConcurrentDictionary>(); ServiceBusClient _serviceBusClient { get; set; } diff --git a/dotnet/src/dotnetcore/Providers/Messaging/GXEventRouter/EventRouterBase.cs b/dotnet/src/dotnetcore/Providers/Messaging/GXEventRouter/EventRouterBase.cs index d8db3aeb0..5b9e802fa 100644 --- a/dotnet/src/dotnetcore/Providers/Messaging/GXEventRouter/EventRouterBase.cs +++ b/dotnet/src/dotnetcore/Providers/Messaging/GXEventRouter/EventRouterBase.cs @@ -6,7 +6,7 @@ namespace GeneXus.Messaging.Common { public abstract class EventRouterBase { - static readonly ILog logger = LogManager.GetLogger(typeof(EventRouterBase)); + static readonly IGXLogger logger = GXLoggerFactory.GetLogger(); internal GXService service; public EventRouterBase() { diff --git a/dotnet/src/dotnetcore/Providers/Messaging/GXEventRouter/EventRouterProvider.cs b/dotnet/src/dotnetcore/Providers/Messaging/GXEventRouter/EventRouterProvider.cs index 410543865..f635107ec 100644 --- a/dotnet/src/dotnetcore/Providers/Messaging/GXEventRouter/EventRouterProvider.cs +++ b/dotnet/src/dotnetcore/Providers/Messaging/GXEventRouter/EventRouterProvider.cs @@ -11,7 +11,7 @@ namespace GeneXus.Messaging.Common [GXApi] public class EventRouterProvider : EventRouterProviderBase { - static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + static readonly IGXLogger logger = GXLoggerFactory.GetLogger(); private static GXService providerService; public EventRouterProvider() { } diff --git a/dotnet/src/dotnetcore/Providers/Messaging/GXEventRouter/EventRouterProviderBase.cs b/dotnet/src/dotnetcore/Providers/Messaging/GXEventRouter/EventRouterProviderBase.cs index 2ab0a67c8..7514c6b04 100644 --- a/dotnet/src/dotnetcore/Providers/Messaging/GXEventRouter/EventRouterProviderBase.cs +++ b/dotnet/src/dotnetcore/Providers/Messaging/GXEventRouter/EventRouterProviderBase.cs @@ -14,7 +14,7 @@ public class EventRouterProviderBase { internal IEventRouter eventRouter = null; public static Assembly assembly; - static readonly ILog logger = LogManager.GetLogger(typeof(EventRouterProviderBase)); + static readonly IGXLogger logger = GXLoggerFactory.GetLogger(); private const string MODULE_DLL = @"GeneXusEventMessaging"; public EventRouterProviderBase() @@ -179,7 +179,7 @@ private GXCloudEvent ToGXCloudEvent(GxUserType evt) internal class ServiceFactory { private static IEventRouter eventRouter; - private static readonly ILog log = LogManager.GetLogger(typeof(Services.ServiceFactory)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public static GXServices GetGXServices() { diff --git a/dotnet/src/dotnetcore/Providers/Messaging/GXMessageBroker/MessageBrokerBase.cs b/dotnet/src/dotnetcore/Providers/Messaging/GXMessageBroker/MessageBrokerBase.cs index 9f1e2ac80..7fbd6a18d 100644 --- a/dotnet/src/dotnetcore/Providers/Messaging/GXMessageBroker/MessageBrokerBase.cs +++ b/dotnet/src/dotnetcore/Providers/Messaging/GXMessageBroker/MessageBrokerBase.cs @@ -6,7 +6,7 @@ namespace GeneXus.Messaging.Common { public abstract class MessageBrokerBase { - static readonly ILog logger = log4net.LogManager.GetLogger(typeof(MessageBrokerBase)); + static readonly IGXLogger logger = GXLoggerFactory.GetLogger(); internal GXService service; public MessageBrokerBase() { diff --git a/dotnet/src/dotnetcore/Providers/Messaging/GXMessageBroker/MessageBrokerProvider.cs b/dotnet/src/dotnetcore/Providers/Messaging/GXMessageBroker/MessageBrokerProvider.cs index c4bc73447..433a9a211 100644 --- a/dotnet/src/dotnetcore/Providers/Messaging/GXMessageBroker/MessageBrokerProvider.cs +++ b/dotnet/src/dotnetcore/Providers/Messaging/GXMessageBroker/MessageBrokerProvider.cs @@ -11,7 +11,7 @@ namespace GeneXus.Messaging.Common [GXApi] public class MessageBrokerProvider : MessageQueue { - static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + static readonly IGXLogger logger = GXLoggerFactory.GetLogger(); private static GXService providerService; public MessageBrokerProvider() { diff --git a/dotnet/src/dotnetcore/Providers/Messaging/GXMessageBroker/MessageQueue.cs b/dotnet/src/dotnetcore/Providers/Messaging/GXMessageBroker/MessageQueue.cs index 9f2a58649..2044de050 100644 --- a/dotnet/src/dotnetcore/Providers/Messaging/GXMessageBroker/MessageQueue.cs +++ b/dotnet/src/dotnetcore/Providers/Messaging/GXMessageBroker/MessageQueue.cs @@ -14,7 +14,7 @@ public class MessageQueue { internal IMessageBroker messageBroker = null; public static Assembly assembly; - static readonly ILog logger = log4net.LogManager.GetLogger(typeof(MessageQueue)); + static readonly IGXLogger logger = GXLoggerFactory.GetLogger(); private const string SDT_MESSAGE_CLASS_NAME = @"SdtMessage"; private const string SDT_MESSAGEPROPERTY_CLASS_NAME = @"SdtMessageProperty"; private const string NAMESPACE = @"GeneXus.Programs.genexusmessagingmessagebroker"; @@ -345,7 +345,7 @@ private BrokerMessage TransformGXUserTypeToBrokerMessage(GxUserType queueMessage internal class ServiceFactory { private static IMessageBroker messageBroker; - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Services.ServiceFactory)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public static GXServices GetGXServices() { diff --git a/dotnet/src/dotnetcore/Providers/Messaging/GXMessageBroker/ServiceSettings.cs b/dotnet/src/dotnetcore/Providers/Messaging/GXMessageBroker/ServiceSettings.cs index c6cf8ce03..d29c55ab0 100644 --- a/dotnet/src/dotnetcore/Providers/Messaging/GXMessageBroker/ServiceSettings.cs +++ b/dotnet/src/dotnetcore/Providers/Messaging/GXMessageBroker/ServiceSettings.cs @@ -7,7 +7,7 @@ namespace GeneXus.Messaging.Common { public class ServiceSettings { - static readonly ILog logger = LogManager.GetLogger(typeof(ServiceSettings)); + static readonly IGXLogger logger = GXLoggerFactory.GetLogger(); internal GXService service; public string serviceNameResolver { get; } diff --git a/dotnet/src/dotnetcore/Providers/Messaging/GXQueue/MessageQueueProvider.cs b/dotnet/src/dotnetcore/Providers/Messaging/GXQueue/MessageQueueProvider.cs index a3cbe8034..93a4ba066 100644 --- a/dotnet/src/dotnetcore/Providers/Messaging/GXQueue/MessageQueueProvider.cs +++ b/dotnet/src/dotnetcore/Providers/Messaging/GXQueue/MessageQueueProvider.cs @@ -11,7 +11,7 @@ namespace GeneXus.Messaging.Common [GXApi] public class MessageQueueProvider : SimpleMessageQueue { - static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + static readonly IGXLogger logger = GXLoggerFactory.GetLogger(); private static GXService providerService; public MessageQueueProvider(){ } diff --git a/dotnet/src/dotnetcore/Providers/Messaging/GXQueue/QueueBase.cs b/dotnet/src/dotnetcore/Providers/Messaging/GXQueue/QueueBase.cs index d8b80fdea..b43c47b1b 100644 --- a/dotnet/src/dotnetcore/Providers/Messaging/GXQueue/QueueBase.cs +++ b/dotnet/src/dotnetcore/Providers/Messaging/GXQueue/QueueBase.cs @@ -10,7 +10,7 @@ namespace GeneXus.Messaging.Common { public abstract class QueueBase { - static readonly ILog logger = log4net.LogManager.GetLogger(typeof(QueueBase)); + static readonly IGXLogger logger = GXLoggerFactory.GetLogger(); internal GXService service; public QueueBase() { diff --git a/dotnet/src/dotnetcore/Providers/Messaging/GXQueue/SimpleMessageQueue.cs b/dotnet/src/dotnetcore/Providers/Messaging/GXQueue/SimpleMessageQueue.cs index e243ca161..86d28e213 100644 --- a/dotnet/src/dotnetcore/Providers/Messaging/GXQueue/SimpleMessageQueue.cs +++ b/dotnet/src/dotnetcore/Providers/Messaging/GXQueue/SimpleMessageQueue.cs @@ -16,7 +16,7 @@ public class SimpleMessageQueue { internal IQueue queue = null; public static Assembly assembly; - static readonly ILog logger = log4net.LogManager.GetLogger(typeof(SimpleMessageQueue)); + static readonly IGXLogger logger = GXLoggerFactory.GetLogger(); private const string SDT_MESSAGE_CLASS_NAME = @"SdtMessage"; private const string SDT_MESSAGEPROPERTY_CLASS_NAME = @"SdtMessageProperty"; private const string SDT_MESSAGERESULT_CLASS_NAME = @"SdtMessageResult"; @@ -434,7 +434,7 @@ protected void QueueErrorMessagesSetup(Exception ex, out GXBaseCollection(); public static GXServices GetGXServices() { diff --git a/dotnet/src/dotnetcore/Providers/OpenTelemetry/OpenTelemetryAzureMonitor/AzureAppInsights.cs b/dotnet/src/dotnetcore/Providers/OpenTelemetry/OpenTelemetryAzureMonitor/AzureAppInsights.cs index 68e6152ae..3477bfb7a 100644 --- a/dotnet/src/dotnetcore/Providers/OpenTelemetry/OpenTelemetryAzureMonitor/AzureAppInsights.cs +++ b/dotnet/src/dotnetcore/Providers/OpenTelemetry/OpenTelemetryAzureMonitor/AzureAppInsights.cs @@ -10,7 +10,7 @@ namespace GeneXus.OpenTelemetry.Azure { public class AzureAppInsights : IOpenTelemetryProvider { - private static readonly ILog log = LogManager.GetLogger(typeof(AzureAppInsights)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private const string APPLICATIONINSIGHTS_CONNECTION_STRING = "APPLICATIONINSIGHTS_CONNECTION_STRING"; public AzureAppInsights(GXService s) @@ -32,8 +32,8 @@ public bool InstrumentAspNetCoreApplication(IServiceCollection services) return true; } else - { - log.Warn("OpenTelemetry Azure Monitor was not initialized due to missing 'APPLICATIONINSIGHTS_CONNECTION_STRING' Environment Variable"); + { + GXLogging.Warn(log, "OpenTelemetry Azure Monitor was not initialized due to missing 'APPLICATIONINSIGHTS_CONNECTION_STRING' Environment Variable"); return false; } } diff --git a/dotnet/src/dotnetcore/Providers/OpenTelemetry/OpenTelemetryLightStep/LightstepProvider.cs b/dotnet/src/dotnetcore/Providers/OpenTelemetry/OpenTelemetryLightStep/LightstepProvider.cs index 228b579ff..8b4f5195a 100644 --- a/dotnet/src/dotnetcore/Providers/OpenTelemetry/OpenTelemetryLightStep/LightstepProvider.cs +++ b/dotnet/src/dotnetcore/Providers/OpenTelemetry/OpenTelemetryLightStep/LightstepProvider.cs @@ -13,7 +13,7 @@ namespace GeneXus.OpenTelemetry.Lightstep public class LightStepOpenTelemetry : IOpenTelemetryProvider { - private static readonly ILog log = LogManager.GetLogger(typeof(LightStepOpenTelemetry)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private const string LIGHTSTEP_INGREST_URL = "ingest.lightstep.com:443"; private const string LIGHTSTEP_ACCESS_TOKEN = "LS_ACCESS_TOKEN"; @@ -27,7 +27,7 @@ public bool InstrumentAspNetCoreApplication(IServiceCollection services) if (string.IsNullOrEmpty(lightstepToken)) { - log.Warn("OpenTelemetry Lightstep was not initialized due to missing 'LS_ACCESS_TOKEN' Environment Variable"); + GXLogging.Warn(log, "OpenTelemetry Lightstep was not initialized due to missing 'LS_ACCESS_TOKEN' Environment Variable"); return false; } diff --git a/dotnet/src/dotnetframework/GxClasses.Win/Process/CommandLine.cs b/dotnet/src/dotnetframework/GxClasses.Win/Process/CommandLine.cs index ad02258b6..b29d1f954 100644 --- a/dotnet/src/dotnetframework/GxClasses.Win/Process/CommandLine.cs +++ b/dotnet/src/dotnetframework/GxClasses.Win/Process/CommandLine.cs @@ -19,8 +19,7 @@ public IProcessHelper GetProcessHelper() } public class GxProcess : IProcessHelper { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Utils.GxProcess)); - + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public short OpenPrintDocument(string commandString) { Process p = new Process(); diff --git a/dotnet/src/dotnetframework/GxClasses/Configuration/ExternalStorage.cs b/dotnet/src/dotnetframework/GxClasses/Configuration/ExternalStorage.cs index f7433d04c..41112ccd6 100644 --- a/dotnet/src/dotnetframework/GxClasses/Configuration/ExternalStorage.cs +++ b/dotnet/src/dotnetframework/GxClasses/Configuration/ExternalStorage.cs @@ -16,8 +16,7 @@ public class ExternalStorage : GxStorageProvider private GXService providerService; - static readonly ILog logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - + static readonly IGXLogger logger = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); public ExternalStorage() { @@ -59,7 +58,7 @@ public bool Create(string name, GXProperties properties, ref GxStorageProvider s } string typeFullName = providerService.ClassName; - logger.Debug("Loading storage provider: "+ typeFullName); + GXLogging.Debug(logger, "Loading storage provider: " + typeFullName); #if !NETCORE Type type = Type.GetType(typeFullName, true, true); #else @@ -70,7 +69,7 @@ public bool Create(string name, GXProperties properties, ref GxStorageProvider s } catch (Exception ex) { - logger.Error("Couldn't connect to external storage provider. ", ex); + GXLogging.Error(logger, "Couldn't connect to external storage provider. ", ex); StorageMessages(ex, messages); return false; } diff --git a/dotnet/src/dotnetframework/GxClasses/Configuration/LogConfiguration.cs b/dotnet/src/dotnetframework/GxClasses/Configuration/LogConfiguration.cs index 38102430c..56b013d94 100644 --- a/dotnet/src/dotnetframework/GxClasses/Configuration/LogConfiguration.cs +++ b/dotnet/src/dotnetframework/GxClasses/Configuration/LogConfiguration.cs @@ -11,7 +11,7 @@ namespace GeneXus.Configuration { internal class LogConfiguration { - private static readonly ILog logger = log4net.LogManager.GetLogger(typeof(LogConfiguration)); + //private static readonly IGXLogger logger = GXLoggerFactory.GetLogger(); public const string USER_LOG_TOPIC = "GeneXusUserLog"; private const string LOG_LEVEL_ENVVAR = "GX_LOG_LEVEL"; @@ -56,7 +56,7 @@ private static void SetupLog4NetFromEnvironmentVariables() IAppender appenderToAdd = h.GetAppenders().FirstOrDefault(a => a.Name == appenderName); if (appenderToAdd == null) { - LogConfiguration.logger.Warn($"Appender '{appenderName}' was not found on Log4Net Config file"); + //LogConfiguration.logger.Warn($"Appender '{appenderName}' was not found on Log4Net Config file"); return; } diff --git a/dotnet/src/dotnetframework/GxClasses/Core/GXApplication.cs b/dotnet/src/dotnetframework/GxClasses/Core/GXApplication.cs index c835ae5d9..f041d445d 100644 --- a/dotnet/src/dotnetframework/GxClasses/Core/GXApplication.cs +++ b/dotnet/src/dotnetframework/GxClasses/Core/GXApplication.cs @@ -293,18 +293,18 @@ public GxHttpContextAccesor(IHttpContextAccessor ctxAccessor) public override IFeatureCollection Features => ctxAccessor.HttpContext.Features; - public override IDictionary Items { get => ctxAccessor.HttpContext.Items; set => ctxAccessor.HttpContext.Items=value; } + public override IDictionary Items { get => ctxAccessor.HttpContext.Items; set => ctxAccessor.HttpContext.Items = value; } public override HttpRequest Request => ctxAccessor.HttpContext.Request; - public override CancellationToken RequestAborted { get => ctxAccessor.HttpContext.RequestAborted; set => ctxAccessor.HttpContext.RequestAborted=value; } - public override IServiceProvider RequestServices { get => ctxAccessor.HttpContext.RequestServices; set => ctxAccessor.HttpContext.RequestServices=value; } + public override CancellationToken RequestAborted { get => ctxAccessor.HttpContext.RequestAborted; set => ctxAccessor.HttpContext.RequestAborted = value; } + public override IServiceProvider RequestServices { get => ctxAccessor.HttpContext.RequestServices; set => ctxAccessor.HttpContext.RequestServices = value; } public override HttpResponse Response => ctxAccessor.HttpContext.Response; - public override ISession Session { get => ctxAccessor.HttpContext.Session; set => ctxAccessor.HttpContext.Session=value; } - public override string TraceIdentifier { get => ctxAccessor.HttpContext.TraceIdentifier; set => ctxAccessor.HttpContext.TraceIdentifier=value; } - public override ClaimsPrincipal User { get => ctxAccessor.HttpContext.User; set => ctxAccessor.HttpContext.User=value; } + public override ISession Session { get => ctxAccessor.HttpContext.Session; set => ctxAccessor.HttpContext.Session = value; } + public override string TraceIdentifier { get => ctxAccessor.HttpContext.TraceIdentifier; set => ctxAccessor.HttpContext.TraceIdentifier = value; } + public override ClaimsPrincipal User { get => ctxAccessor.HttpContext.User; set => ctxAccessor.HttpContext.User = value; } public override WebSocketManager WebSockets => ctxAccessor.HttpContext.WebSockets; @@ -321,7 +321,8 @@ internal class GxApplication [Serializable] public class GxContext : IGxContext { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Application.GxContext)); + private static IGXLogger log = null; + public static bool configurationLoaded = Config.configLoaded; internal static string GX_SPA_REQUEST_HEADER = "X-SPA-REQUEST"; internal static string GX_SPA_REDIRECT_URL = "X-SPA-REDIRECT-URL"; internal const string GXLanguage = "GXLanguage"; @@ -454,6 +455,26 @@ public static GxContext CreateDefaultInstance() context.SetDefaultTheme(theme); return context; } + + static IGXLogger Logger + { + get + { + if (configurationLoaded) + { + if (log == null) + { + log = GXLoggerFactory.GetLogger(); + return log; + } + return log; + } + else + return null; + } + + } + public GxContext() { _DataStores = new ArrayList(2); @@ -461,7 +482,9 @@ public GxContext() _errorHandlerInfo = new GxErrorHandlerInfo(); setContext(this); httpContextVars = new GxHttpContextVars(); - GXLogging.Debug(log, "GxContext.Ctr Default handle:", () => _handle.ToString()); + + GXLogging.Debug(Logger, "GxContext.Ctr Default handle:", () => _handle.ToString()); + if (GxApplication.MainContext == null && !(IsHttpContext || GxContext.IsRestService)) GxApplication.MainContext = this; } @@ -476,12 +499,12 @@ public GxContext(int handle, string location) } public GxContext(String location) { - GXLogging.Debug(log, "GxContext.Ctr, parameters location=", location); + GXLogging.Debug(Logger, "GxContext.Ctr, parameters location=", location); _DataStores = new ArrayList(2); _errorHandlerInfo = new GxErrorHandlerInfo(); setContext(this); httpContextVars = new GxHttpContextVars(); - GXLogging.Debug(log, "Return GxContext.Ctr"); + GXLogging.Debug(Logger, "Return GxContext.Ctr"); } public GxContext(int handle, ArrayList dataStores, HttpContext httpContext) @@ -572,7 +595,7 @@ public CookieContainer GetCookieContainer(string url, bool includeCookies = true } catch (Exception ex) { - GXLogging.Debug(log, ex, "GetCookieContainer error url:", url); + GXLogging.Debug(Logger, ex, "GetCookieContainer error url:", url); } return new CookieContainer(); @@ -709,7 +732,7 @@ public static bool GetHttpRequestPostedFile(IGxContext gxContext, string varName if (ext != null) ext = ext.TrimStart('.'); string filePath = FileUtil.getTempFileName(tempDir); - GXLogging.Debug(log, "cgiGet(" + varName + "), fileName:" + filePath); + GXLogging.Debug(Logger, "cgiGet(" + varName + "), fileName:" + filePath); GxFile file = new GxFile(tempDir, filePath, GxFileType.PrivateAttribute); filePath = file.Create(pf.InputStream); string fileGuid = GxUploadHelper.GetUploadFileGuid(); @@ -980,12 +1003,12 @@ private bool CheckFileExists(string fileName) { string path = Path.Combine(this.GetPhysicalPath(), fileName); fileExists = File.Exists(path); - GXLogging.Debug(log, $"Searching if file exists ({fileName}). Found: {fileExists}"); + GXLogging.Debug(Logger, $"Searching if file exists ({fileName}). Found: {fileExists}"); } catch (Exception e) { fileExists = false; - GXLogging.Error(log, e, $"Failed searching for a file ({fileName})"); + GXLogging.Error(Logger, e, $"Failed searching for a file ({fileName})"); } return fileExists; } @@ -993,11 +1016,8 @@ private bool CheckFileExists(string fileName) public void StatusMessage(string message) { StackFrame frame = new StackFrame(1); -#if NETCORE - ILog statusLog = log4net.LogManager.GetLogger(frame.GetMethod().DeclaringType); -#else - ILog statusLog = log4net.LogManager.GetLogger(frame.GetMethod().DeclaringType.FullName); -#endif + + IGXLogger statusLog = GXLoggerFactory.GetLogger(frame.GetMethod().DeclaringType.FullName); GXLogging.Info(statusLog, message); Console.WriteLine(message); } @@ -1405,7 +1425,7 @@ public void CloseConnections() } catch (Exception ex) { - GXLogging.Error(log, "Error closing report", ex); + GXLogging.Error(Logger, "Error closing report", ex); } } _reportHandlerToClose.Clear(); @@ -1470,7 +1490,7 @@ public void Disconnect() { foreach (IGxDataStore ds in _DataStores) ds.Disconnect(); - GXLogging.Debug(log, "Local Disconnect"); + GXLogging.Debug(Logger, "Local Disconnect"); } public void RollbackDataStores() @@ -1801,7 +1821,7 @@ internal string AbsoluteUri { absoluteUri = String.Format("{0}://{1}{2}", GetServerSchema(), _HttpContext.Request.Headers["Host"], _HttpContext.Request.GetRawUrl()); } - GXLogging.DebugSanitized(log, "AbsoluteUri dynamicport:", absoluteUri); + GXLogging.DebugSanitized(Logger, "AbsoluteUri dynamicport:", absoluteUri); return absoluteUri; } else @@ -2144,7 +2164,7 @@ static internal short GetHttpSecure(HttpContext httpContext) return 0; if (httpContext.Request.GetIsSecureFrontEnd()) { - GXLogging.Debug(log, "Front-End-Https header activated"); + GXLogging.Debug(Logger, "Front-End-Https header activated"); return 1; } else @@ -2473,7 +2493,7 @@ private byte SetCustomHttpHeader(string name, string value) Cache.AppendCacheExtension("no-store, must-revalidate"); break; default: - GXLogging.Warn(log, String.Format("Could not set Cache Control Http Header Value '{0}' to HttpResponse", value)); + GXLogging.Warn(Logger, String.Format("Could not set Cache Control Http Header Value '{0}' to HttpResponse", value)); break; } } @@ -2495,7 +2515,7 @@ private byte SetCustomHttpHeader(string name, string value) }catch (PlatformNotSupportedException ex) { _HttpContext.Response.AppendHeader(name, value); - GXLogging.Warn(log, ex, "SetHeader ", name, value); + GXLogging.Warn(Logger, ex, "SetHeader ", name, value); } } #else @@ -2516,7 +2536,7 @@ private byte SetCustomHttpHeader(string name, string value) _HttpContext.Response.AddHeader(HeaderNames.CacheControl, "private"); break; default: - GXLogging.Warn(log, String.Format("Could not set Cache Control Http Header Value '{0}' to HttpResponse", value)); + GXLogging.Warn(Logger, String.Format("Could not set Cache Control Http Header Value '{0}' to HttpResponse", value)); break; } } @@ -2529,7 +2549,7 @@ private byte SetCustomHttpHeader(string name, string value) } catch (Exception ex) { - GXLogging.Error(log, ex, "Error adding header ", name, value); + GXLogging.Error(Logger, ex, "Error adding header ", name, value); return 1; } } @@ -2883,7 +2903,7 @@ internal static int GetServerPort(HttpRequest request, bool isSecure) } catch (Exception ex) { - GXLogging.Error(log, "GetServerPort error", ex); + GXLogging.Error(Logger, "GetServerPort error", ex); return 0; } @@ -2925,7 +2945,7 @@ private bool FrontEndHttps() { if (CheckHeaderValue("Front-End-Https", "on") || CheckHeaderValue("X-Forwarded-Proto", "https")) { - GXLogging.Debug(log, "Front-End-Https header activated"); + GXLogging.Debug(Logger, "Front-End-Https header activated"); return true; } else @@ -2980,7 +3000,7 @@ public string GetPhysicalPath() } catch (Exception ex) { - GXLogging.Debug(log, "GetPhysicalPath error", ex); + GXLogging.Debug(Logger, "GetPhysicalPath error", ex); _physicalPath = String.Empty; } } @@ -3269,7 +3289,7 @@ public bool ExecuteBeforeConnect(IGxDataStore datastore) if (!configuredEventHandling) configEventHandling(); if (beforeConnectObj != null) { - GXLogging.Debug(log, "ExecuteBeforeConnect"); + GXLogging.Debug(Logger, "ExecuteBeforeConnect"); ClassLoader.ExecuteVoidRef(beforeConnectObj, "execute", new Object[] { datastore }); return true; } @@ -3283,7 +3303,7 @@ public bool ExecuteAfterConnect(String datastoreName) if (!configuredEventHandling) configEventHandling(); if (afterConnectObj != null) { - GXLogging.Debug(log, "ExecuteAfterConnect"); + GXLogging.Debug(Logger, "ExecuteAfterConnect"); ClassLoader.ExecuteVoidRef(afterConnectObj, "execute", new Object[] { datastoreName }); return true; } @@ -3301,7 +3321,7 @@ public void SetProperty(string key, string value) { if (HttpContext != null && HttpContext.Session != null) { - GXLogging.DebugSanitized(log, "HttpContext.Session.setProperty(", key, ")=", value); + GXLogging.DebugSanitized(Logger, "HttpContext.Session.setProperty(", key, ")=", value); WriteSessionKey(key, value); } else @@ -3310,7 +3330,7 @@ public void SetProperty(string key, string value) { _properties = new Hashtable(); } - GXLogging.DebugSanitized(log, "GxContext.Properties.getProperty(", key, ")=", value); + GXLogging.DebugSanitized(Logger, "GxContext.Properties.getProperty(", key, ")=", value); _properties[key] = value; } } @@ -3350,7 +3370,7 @@ public object GetContextProperty(string key) public string PathToUrl(string path) { - GXLogging.Debug(log, "PathToUrl:", () => GetContextPath() + " relativePath:" + PathToRelativeUrl(path)); + GXLogging.Debug(Logger, "PathToUrl:", () => GetContextPath() + " relativePath:" + PathToRelativeUrl(path)); #pragma warning disable SYSLIB0013 // EscapeUriString return Uri.EscapeUriString(GetContextPath()) + PathToRelativeUrl(path, false); #pragma warning disable SYSLIB0013 // EscapeUriString @@ -3570,11 +3590,11 @@ public OlsonTimeZone ClientTimeZone if (_currentTimeZone != null) return _currentTimeZone; string sTZ = _HttpContext == null ? "" : (string)_HttpContext.Request.Headers[GX_REQUEST_TIMEZONE]; - GXLogging.DebugSanitized(log, "ClientTimeZone GX_REQUEST_TIMEZONE header:", sTZ); + GXLogging.DebugSanitized(Logger, "ClientTimeZone GX_REQUEST_TIMEZONE header:", sTZ); if (String.IsNullOrEmpty(sTZ)) { sTZ = (string)GetCookie(GX_REQUEST_TIMEZONE); - GXLogging.Debug(log, "ClientTimeZone GX_REQUEST_TIMEZONE cookie:", sTZ); + GXLogging.Debug(Logger, "ClientTimeZone GX_REQUEST_TIMEZONE cookie:", sTZ); } try { @@ -3582,14 +3602,14 @@ public OlsonTimeZone ClientTimeZone } catch (Exception e1) { - GXLogging.Warn(log, "ClientTimeZone _currentTimeZone error", e1); + GXLogging.Warn(Logger, "ClientTimeZone _currentTimeZone error", e1); try { _currentTimeZone = TimeZoneUtil.GetInstanceFromWin32Id(TimeZoneInfo.Local.Id); } catch (Exception e2) { - GXLogging.Warn(log, "ClientTimeZone GetInstanceFromWin32Id error", e2); + GXLogging.Warn(Logger, "ClientTimeZone GetInstanceFromWin32Id error", e2); Preferences.StorageTimeZonePty storagePty = Preferences.getStorageTimezonePty(); if (storagePty == Preferences.StorageTimeZonePty.Undefined) _currentTimeZone = null; @@ -3607,16 +3627,16 @@ internal string ClientTimeZoneId if (_currentTimeZoneId != null) return _currentTimeZoneId; string sTZ = _HttpContext == null ? "" : (string)_HttpContext.Request.Headers[GX_REQUEST_TIMEZONE]; - GXLogging.DebugSanitized(log, "ClientTimeZone GX_REQUEST_TIMEZONE header:", sTZ); + GXLogging.DebugSanitized(Logger, "ClientTimeZone GX_REQUEST_TIMEZONE header:", sTZ); if (String.IsNullOrEmpty(sTZ)) { sTZ = (string)GetCookie(GX_REQUEST_TIMEZONE); - GXLogging.Debug(log, "ClientTimeZone GX_REQUEST_TIMEZONE cookie:", sTZ); + GXLogging.Debug(Logger, "ClientTimeZone GX_REQUEST_TIMEZONE cookie:", sTZ); } if (!DateTimeUtil.ValidTimeZone(sTZ)) { sTZ = (string)GetUndecodedCookie(GX_REQUEST_TIMEZONE); - GXLogging.Debug(log, "Try reading undecoded ClientTimeZone GX_REQUEST_TIMEZONE cookie:", sTZ); + GXLogging.Debug(Logger, "Try reading undecoded ClientTimeZone GX_REQUEST_TIMEZONE cookie:", sTZ); } try { @@ -3627,10 +3647,10 @@ internal string ClientTimeZoneId string invalidTimezone = DateTimeZoneProviders.Tzdb[sTZ].Id; }catch(Exception ex)//DateTimeZoneNotFound { - GXLogging.Warn(log, $"Client timezone not found: {sTZ}", ex); + GXLogging.Warn(Logger, $"Client timezone not found: {sTZ}", ex); } _currentTimeZoneId = DateTimeZoneProviders.Tzdb.GetSystemDefault().Id; - GXLogging.Warn(log, $"Setting Client timezone to System default: {_currentTimeZoneId}"); + GXLogging.Warn(Logger, $"Setting Client timezone to System default: {_currentTimeZoneId}"); } else { @@ -3639,7 +3659,7 @@ internal string ClientTimeZoneId } catch (Exception e1) { - GXLogging.Warn(log, "ClientTimeZone GetInstanceFromWin32Id error", e1); + GXLogging.Warn(Logger, "ClientTimeZone GetInstanceFromWin32Id error", e1); Preferences.StorageTimeZonePty storagePty = Preferences.getStorageTimezonePty(); if (storagePty == Preferences.StorageTimeZonePty.Undefined) _currentTimeZoneId = null; @@ -3744,7 +3764,7 @@ Hashtable Images string imgDir = ""; if (String.IsNullOrEmpty(dir) && _HttpContext == null) { - GXLogging.Debug(log, "Searching for txt files .."); + GXLogging.Debug(Logger, "Searching for txt files .."); int srchIx = 0; string[] paths = new string[] { ".\\", "..\\" }; bool found = false; @@ -3760,12 +3780,12 @@ Hashtable Images } } imgDir = dir; - GXLogging.Debug(log, $"{imgDir} txt file found"); + GXLogging.Debug(Logger, $"{imgDir} txt file found"); } else { imageFiles = Directory.GetFiles(dir, "*.txt"); - GXLogging.Debug(log, "imageFiles found"); + GXLogging.Debug(Logger, "imageFiles found"); } string KBPrefix = String.Empty; @@ -3829,7 +3849,7 @@ Hashtable Images } catch (FileNotFoundException) { - GXLogging.Debug(log, $"{filename} file not found"); + GXLogging.Debug(Logger, $"{filename} file not found"); } } } @@ -3848,7 +3868,7 @@ public string GetImagePath(string id, string KBId, string theme) return ret; else { - GXLogging.Debug(log, "Image not found at Images.txt. Image id:", () => KBId + id + " language:" + lang + " theme:" + theme); + GXLogging.Debug(Logger, "Image not found at Images.txt. Image id:", () => KBId + id + " language:" + lang + " theme:" + theme); return id; } } @@ -3972,7 +3992,7 @@ static public DateTime StartupDate public void SetSubmitInitialConfig(IGxContext context) { - GXLogging.Debug(log, "SetSubmitInitialConfig:", () => _handle.ToString() + " clientid:" + context.ClientID); + GXLogging.Debug(Logger, "SetSubmitInitialConfig:", () => _handle.ToString() + " clientid:" + context.ClientID); this._isSumbited = true; this.SetDefaultTheme(context.GetTheme(), context.GetThemeisDSO()); this.SetPhysicalPath(context.GetPhysicalPath()); diff --git a/dotnet/src/dotnetframework/GxClasses/Core/GXUtils.cs b/dotnet/src/dotnetframework/GxClasses/Core/GXUtils.cs index 1f9e63a42..c5c616f58 100644 --- a/dotnet/src/dotnetframework/GxClasses/Core/GXUtils.cs +++ b/dotnet/src/dotnetframework/GxClasses/Core/GXUtils.cs @@ -267,7 +267,7 @@ static string NormalizeNewLine(string value) public class FileIO { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Utils.FileIO)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); const short GX_ASCDEL_BADFMTSTR = -10; const short GX_ASCDEL_WRITEERROR = -9; const short GX_ASCDEL_INVALIDDATE = -7; diff --git a/dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs b/dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs index 06fb16db1..cd0632fe5 100644 --- a/dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs +++ b/dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs @@ -90,7 +90,7 @@ public static void NextBytes(byte[] result) public class NumberUtil { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Utils.NumberUtil)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private NumberFormatInfo numberFormat; public NumberUtil(NumberFormatInfo numFmt) @@ -504,7 +504,7 @@ public string FormatValid(string oldText) public class StringUtil { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Utils.StringUtil)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private NumberFormatInfo numFmtInfo; private const int STR_LEN_DEFAULT = 10; @@ -1995,7 +1995,8 @@ public static string ToCamelCase(this string str) } public class DateTimeUtil { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Utils.DateTimeUtil)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + private CultureInfo cultureInfo; public static bool useConfigForDates; public static bool useConfigForTimes; @@ -3585,7 +3586,7 @@ static public DateTime FromTimeZone(DateTime dt, String sTZ, IGxContext context) public class FileUtil { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Utils.FileUtil)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public static byte DeleteFile(string fileName) { try @@ -4015,7 +4016,7 @@ internal static string SafeCombine(string basePath, string fileName) public class GXUtil { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Utils.GXUtil)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); #if !NETCORE static Hashtable domains; static string DOMAINS_FILE; @@ -5551,7 +5552,7 @@ public string IniReadValue(string Section, string Key) #endif public static class GXDbFile { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Utils.GXDbFile)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); private static Regex schemeRegex = new Regex("^" + Scheme + ":", RegexOptions.Compiled); @@ -5772,8 +5773,7 @@ public static string PathToUrl(string path, bool absUrl, IGxContext context = nu public static class GxImageUtil { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GxImageUtil)); - + static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); private static Bitmap BitmapCreateFromStream(string filePathOrUrl) { Uri uri; @@ -6197,7 +6197,7 @@ public static string EncodeNonAsciiCharacters(string value) } internal class ThreadUtil { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(ThreadUtil)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private static ConcurrentDictionary events = new ConcurrentDictionary(); const int MAX_WAIT_HANDLES = 64; internal static void Submit(WaitCallback callbak, object state) diff --git a/dotnet/src/dotnetframework/GxClasses/Core/Web/HttpAjaxContext.cs b/dotnet/src/dotnetframework/GxClasses/Core/Web/HttpAjaxContext.cs index 6f16bd50a..2180ad8a4 100644 --- a/dotnet/src/dotnetframework/GxClasses/Core/Web/HttpAjaxContext.cs +++ b/dotnet/src/dotnetframework/GxClasses/Core/Web/HttpAjaxContext.cs @@ -122,7 +122,7 @@ public bool isParmModified(string fieldName, object value) public class HttpAjaxContext : IHttpAjaxContext { private IGxContext _context; - static readonly ILog log = log4net.LogManager.GetLogger(typeof(HttpAjaxContext)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private Stack cmpContents = new Stack(); private GXAjaxCommandCollection commands = new GXAjaxCommandCollection(); private JArray _AttValues = new JArray(); diff --git a/dotnet/src/dotnetframework/GxClasses/Core/gxconfig.cs b/dotnet/src/dotnetframework/GxClasses/Core/gxconfig.cs index 7254ff5e8..949033146 100644 --- a/dotnet/src/dotnetframework/GxClasses/Core/gxconfig.cs +++ b/dotnet/src/dotnetframework/GxClasses/Core/gxconfig.cs @@ -29,7 +29,8 @@ namespace GeneXus.Configuration public class Config { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Configuration.Config)); + private static IGXLogger log = null; + public const string GX_LANG_SPA = "spa"; public const string GX_LANG_POR = "por"; public const string GX_LANG_ITA = "ita"; @@ -42,7 +43,7 @@ public class Config private static string configFileName; public static string loadedConfigFile; private static bool configLog = true; - private static bool configLoaded; + public static bool configLoaded; static NameValueCollection _config; static ConcurrentDictionary s_confMapping; const string CONFMAPPING_FILE = "confmapping.json"; @@ -80,7 +81,11 @@ public static void ParseArgs(ref string[] args) } } - LogConfiguration.SetupLog4Net(); + Config.GetValueOf("LOG_OUTPUT", out string logProvider); + if (logProvider == "ASPNetTraceAppender" || logProvider == "ConsoleAppender" || logProvider == "EventLogAppender" || logProvider == "RollingFile") + { + LogConfiguration.SetupLog4Net(); + } } private static void RemoveArg(ref string[] args, ref int i) @@ -440,10 +445,14 @@ public static CultureInfo GetCultureForLang(string lang) const string ITextSharpAssemblyName = "itextsharp"; private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { - var requestedAssembly = new AssemblyName(args.Name); - if (requestedAssembly.Name == Log4NetShortName){ - requestedAssembly.Version = Log4NetVersion; - return Assembly.Load(requestedAssembly); + Config.GetValueOf("LOG_OUTPUT", out string logProvider); + if (logProvider == "ASPNetTraceAppender" || logProvider == "ConsoleAppender" || logProvider == "EventLogAppender" || logProvider == "RollingFile") + { + var requestedAssembly = new AssemblyName(args.Name); + if (requestedAssembly.Name == Log4NetShortName){ + requestedAssembly.Version = Log4NetVersion; + return Assembly.Load(requestedAssembly); + } } if (args.Name.StartsWith(ConfigurationManagerBak)) @@ -513,19 +522,22 @@ static NameValueCollection config { if (_config == null) { + + bool isNetTrustException = false; + Exception netTrustedException = null; try { AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; } catch (Exception ex) { - GXLogging.Info(log, ".NET trust level is lower than full", ex.Message); + isNetTrustException = true; + netTrustedException = ex; } string logConfigSource; - configLoaded = true; if (configFileName != null) { - if (log.IsDebugEnabled) loadedConfigFile = configFileName; + loadedConfigFile = configFileName; _config = loadConfig(configFileName, out logConfigSource); if (!string.IsNullOrEmpty(logConfigSource)) logConfig(logConfigSource); @@ -534,6 +546,8 @@ static NameValueCollection config return _config; } #if !NETCORE + log = GXLoggerFactory.GetLogger(); + if (GxContext.IsHttpContext && File.Exists(Path.Combine(GxContext.StaticPhysicalPath(), "web.config"))) { @@ -582,31 +596,50 @@ static NameValueCollection config string startupDir = FileUtil.GetStartupDirectory(); string appSettings = "appsettings.json"; string clientConfig = "client.exe.config"; - string logConfigFile = GxContext.IsHttpContext ? "log.config" : "log.console.config"; + + string logConfigurationSource = string.Empty; if (File.Exists(Path.Combine(basePath, appSettings))) { _config = loadConfigJson(basePath, appSettings); - logConfig(Path.Combine(basePath, logConfigFile)); + } else if (File.Exists(appSettings)) { _config = loadConfigJson(currentDir, appSettings); - logConfig(logConfigFile); + } else if (File.Exists(Path.Combine(startupDir, appSettings))) { _config = loadConfigJson(startupDir, appSettings); - logConfig(Path.Combine(startupDir, logConfigFile)); + } else if (File.Exists(clientConfig)) { _config = loadConfig(clientConfig, out logConfigSource); - if (!string.IsNullOrEmpty(logConfigSource)) - logConfig(logConfigSource); + logConfigurationSource = logConfigSource; + + } + configLoaded = true; + GxContext.configurationLoaded = configLoaded; + log = GXLoggerFactory.GetLogger(); + + string logConfigFile = GxContext.IsHttpContext ? "log.config" : "log.console.config"; + if (File.Exists(Path.Combine(basePath, appSettings))) + logConfig(Path.Combine(basePath, logConfigFile)); + + else if (File.Exists(appSettings)) + logConfig(logConfigFile); + + else if (File.Exists(Path.Combine(startupDir, appSettings))) + logConfig(Path.Combine(startupDir, logConfigFile)); + + else if (File.Exists(clientConfig)) + if (!string.IsNullOrEmpty(logConfigurationSource)) + logConfig(logConfigurationSource); else logConfig(logConfigFile); - } + try { Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); @@ -616,7 +649,11 @@ static NameValueCollection config GXLogging.Info(log, "Could not register encoding provider", ex.Message); } #endif + if (isNetTrustException) + GXLogging.Info(log, ".NET trust level is lower than full", netTrustedException.Message); + } + } } return _config; @@ -663,7 +700,7 @@ static NameValueCollection loadConfigJson(string baseDir, string appSettings) #endif private static void logConfig(string filename) { - if (configLog) + if (configLog) { try { @@ -687,6 +724,7 @@ private static void logConfig(string filename) } #endif GXLogging.Debug(log, "GxClasses version:", GxContext.StdClassesVersion()); + } catch (Exception ex) { @@ -703,7 +741,7 @@ static NameValueCollection loadConfig(string filename) } static NameValueCollection loadConfig(string filename, out string logConfigSource) { - GXLogging.Debug(log, "Start loadConfig, filename '", filename, "'"); + //GXLogging.Debug(log, "Start loadConfig, filename '", filename, "'"); NameValueCollection cfg = new NameValueCollection(StringComparer.Ordinal); //Case sensitive logConfigSource = null; if (!File.Exists(filename)) @@ -752,7 +790,7 @@ static NameValueCollection loadConfig(string filename, out string logConfigSourc } } } - GXLogging.Debug(log, "Return loadConfig"); + //GXLogging.Debug(log, "Return loadConfig"); return cfg; } private static string MappedValue(string key, string value) @@ -767,7 +805,7 @@ private static string MappedValue(string key, string value) } public class Preferences { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Configuration.Preferences)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); static object syncRoot = new Object(); static Hashtable cachingTtl; static string _applicationPath = ""; diff --git a/dotnet/src/dotnetframework/GxClasses/Cryptography/GXAsymmetricEncryption.cs b/dotnet/src/dotnetframework/GxClasses/Cryptography/GXAsymmetricEncryption.cs index f9c110a7b..6c4840057 100644 --- a/dotnet/src/dotnetframework/GxClasses/Cryptography/GXAsymmetricEncryption.cs +++ b/dotnet/src/dotnetframework/GxClasses/Cryptography/GXAsymmetricEncryption.cs @@ -1,18 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.IO; -using log4net; using GeneXus.Cryptography.CryptoException; using GeneXus.Cryptography.Encryption; namespace GeneXus.Cryptography { - public class GXAsymmetricEncryption + public class GXAsymmetricEncryption { - private static readonly ILog _log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - private int _lastError; + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + private int _lastError; private string _lastErrorDescription; private GXCertificate _cert; private IGXAsymmetricEncryption _asymAlg; @@ -62,7 +56,7 @@ public string Encrypt(string text) catch (EncryptionException e) { SetError(1, e.Message); - _log.Error("Encryption Error", e); + GXLogging.Error(log, "Encryption Error", e); } } return encrypted; @@ -89,7 +83,7 @@ public string Decrypt(string text) catch (EncryptionException e) { SetError(1, e.Message); - _log.Error("Encryption Error", e); + GXLogging.Error(log, "Encryption Error", e); } } return decrypted; diff --git a/dotnet/src/dotnetframework/GxClasses/Cryptography/GXCertificate.cs b/dotnet/src/dotnetframework/GxClasses/Cryptography/GXCertificate.cs index 7a195f954..3c19b6dc4 100644 --- a/dotnet/src/dotnetframework/GxClasses/Cryptography/GXCertificate.cs +++ b/dotnet/src/dotnetframework/GxClasses/Cryptography/GXCertificate.cs @@ -1,8 +1,7 @@ using System; -using System.Security.Cryptography.X509Certificates; using System.IO; using System.Security.Cryptography; -using log4net; +using System.Security.Cryptography.X509Certificates; using GeneXus.Utils; @@ -10,9 +9,9 @@ namespace GeneXus.Cryptography { public class GXCertificate { - static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); - private X509Certificate2 _cert; + private X509Certificate2 _cert; private int _lastError; private string _lastErrorDescription; private string _password; diff --git a/dotnet/src/dotnetframework/GxClasses/Cryptography/GXSymmetricEncryption.cs b/dotnet/src/dotnetframework/GxClasses/Cryptography/GXSymmetricEncryption.cs index 8bf205372..816093187 100644 --- a/dotnet/src/dotnetframework/GxClasses/Cryptography/GXSymmetricEncryption.cs +++ b/dotnet/src/dotnetframework/GxClasses/Cryptography/GXSymmetricEncryption.cs @@ -1,19 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Security.Cryptography; -using System.IO; -using log4net; +using System; using GeneXus.Cryptography.CryptoException; using GeneXus.Cryptography.Encryption; namespace GeneXus.Cryptography { - public class GXSymmetricEncryption + public class GXSymmetricEncryption { - private static readonly ILog _log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - private const string DEFAULT_SYM_ALGORITHM = "DES"; + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + private const string DEFAULT_SYM_ALGORITHM = "DES"; private int _lastError; private string _lastErrorDescription; private IGXSymmetricEncryption _symAlg; // Algorithm instance @@ -81,7 +75,7 @@ public string Encrypt(string text) catch (EncryptionException e) { SetError(2, e.Message); - _log.Error(e); + GXLogging.Error(log, e); } } return encrypted; @@ -100,7 +94,7 @@ public string Decrypt(string text) catch (EncryptionException e) { SetError(3, e.Message); - _log.Error(e); + GXLogging.Error(log, e); } } return decrypted; diff --git a/dotnet/src/dotnetframework/GxClasses/Data/GXDataADO.cs b/dotnet/src/dotnetframework/GxClasses/Data/GXDataADO.cs index 206a66c79..8e7453545 100644 --- a/dotnet/src/dotnetframework/GxClasses/Data/GXDataADO.cs +++ b/dotnet/src/dotnetframework/GxClasses/Data/GXDataADO.cs @@ -11,6 +11,7 @@ using GeneXus.XML; using GxClasses.Helpers; using log4net; +using log4net.Core; using System; using System.Collections; using System.Collections.Concurrent; @@ -21,7 +22,6 @@ using System.Reflection; using System.Threading; using TZ4Net; - namespace GeneXus.Data.ADO { @@ -64,7 +64,7 @@ public override void DecOpenHandlesImpl(GxConnection con) public class GxConnectionManager :IGxConnectionManager { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Data.ADO.GxConnectionManager)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private static volatile GxConnectionManager instance; private static object instanceSync = new Object(); @@ -345,7 +345,7 @@ public class GxConnection: MarshalByRefObject, IGxConnection public class GxConnection: IGxConnection #endif { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Data.ADO.GxConnection)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private IDbTransaction transaction; private short lastErrorCode; private string lastErrorMsg; @@ -1319,7 +1319,7 @@ public ParDef(string name, GXType type, int size, int scale) public class GxCommand: IGxDbCommand { internal List ParmDefinition; - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Data.ADO.GxCommand)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); string stmt; String stmtId; GxParameterCollection parameters; @@ -2411,7 +2411,7 @@ internal void AfterCreateCommand() public class GxDataStore : IGxDataStore { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GxDataStore)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); string id; IGxConnection connection; int handle; diff --git a/dotnet/src/dotnetframework/GxClasses/Data/GXDataCommon.cs b/dotnet/src/dotnetframework/GxClasses/Data/GXDataCommon.cs index 35b966913..e94103aea 100644 --- a/dotnet/src/dotnetframework/GxClasses/Data/GXDataCommon.cs +++ b/dotnet/src/dotnetframework/GxClasses/Data/GXDataCommon.cs @@ -4,7 +4,6 @@ using System.IO; using System.Text; using System.Threading; -using log4net; using GeneXus.Application; using GeneXus.Cache; using GeneXus.Configuration; @@ -297,7 +296,8 @@ public enum GxErrorMask public abstract class GxDataRecord : IGxDataRecord { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Data.GxDataRecord)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + public static int RETRY_SLEEP = 500; //500 milliseconds. protected string m_connectionString; protected string m_datasource; @@ -1188,8 +1188,8 @@ public void Clear() public class SqlUtil { public static Hashtable mapping; - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Data.SqlUtil)); - + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + public static string SqlTypeToDbType(SqlParameter parameter) { SqlDbType type = parameter.SqlDbType; @@ -1464,8 +1464,7 @@ public static String GetKeyStmtValues(GxParameterCollection parameters, public class GxSqlDataReader : GxDataReader { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Data.GxSqlDataReader)); - + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public GxSqlDataReader(IGxConnectionManager connManager, GxDataRecord dr, IGxConnection connection, GxParameterCollection parameters, string stmt, ushort fetchSize,bool forFirst, int handle, bool withCached, SlidingTime expiration, bool dynStmt):base(connManager, dr, connection, parameters, stmt, fetchSize, forFirst, handle, withCached, expiration, dynStmt) @@ -1583,7 +1582,7 @@ public override decimal GetDecimal(int i) } public class GxSqlServer : GxDataRecord { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Data.GxSqlServer)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private static int MAX_NET_DECIMAL_PRECISION = 28; private static int MAX_GX_DECIMAL_SCALE = 15; @@ -2168,7 +2167,7 @@ public override string ConcatOp(int pos) public class GxDataReader: IDataReader { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Data.GxDataReader)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); protected IDataReader reader; protected GxParameterCollection parameters; protected int fetchSize; @@ -2541,7 +2540,8 @@ public int GetOrdinal(string name) public class GxConnectionCache { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Data.GxConnectionCache)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + private static int MAX_SIZE=Preferences.GetMaximumOpenCursors(); private SqlCommand fetchCommand; @@ -2647,6 +2647,7 @@ public void AddPreparedStmt(string stmt, int cursorId) if (!preparedStmtCache.TryGetValue(stmt, out s)) { GXLogging.Info(log, "AddPreparedStmt, totalCachedStmtCursors:" + totalCachedCursors + ", cursorId: " + cursorId + ", stmt:" + stmt); + //GXLogging.Info(log, "AddPreparedStmt, totalCachedStmtCursors: {totalCachedCursors} cursorId: {cursorId} stmt {stmt}",totalCachedCursors.ToString(),cursorId.ToString(),stmt); totalCachedCursors++; CheckCacheSize(); @@ -3130,7 +3131,8 @@ private void InitCommands() public class GxPreparedStatementCache : Dictionary { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Data.GxPreparedStatementCache)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + private IGxConnection conn; public GxPreparedStatementCache(IGxConnection connection, int maxSize):base(maxSize) @@ -3183,7 +3185,7 @@ public void dump() public class GxSqlCursorDataReader: IDataReader { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Data.GxSqlCursorDataReader)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private static int STARTPOS = -1; private int pos= STARTPOS; private ushort fetchSize; @@ -4124,7 +4126,7 @@ public string ValueList(IList Values) sealed internal class MssqlConnectionWrapper : GxAbstractConnectionWrapper { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Data.MssqlConnectionWrapper)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); int sqlserver7 = -1; int sqlserver9 = -1; @@ -4241,7 +4243,7 @@ public override bool IsSQLServer9() public abstract class GxAbstractConnectionWrapper : IDbConnection { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Data.GxAbstractConnectionWrapper)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); protected short m_spid; protected IDbConnection _connection; protected bool m_autoCommit; @@ -4380,7 +4382,7 @@ public virtual short RollbackSavePoint(IDbTransaction transaction, string savepo public class GxCacheDataReader: IDataReader { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Data.GxCacheDataReader)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); protected GxArrayList block; protected int pos; int blockSize; diff --git a/dotnet/src/dotnetframework/GxClasses/Data/GXDataDb2.cs b/dotnet/src/dotnetframework/GxClasses/Data/GXDataDb2.cs index a3849f245..ea570daad 100644 --- a/dotnet/src/dotnetframework/GxClasses/Data/GXDataDb2.cs +++ b/dotnet/src/dotnetframework/GxClasses/Data/GXDataDb2.cs @@ -116,7 +116,8 @@ protected override string BuildConnectionString(string datasourceName, string us public class GxDb2 : GxDataRecord { - static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); + public static string SQL_NULL_DATE_10="0000-00-00"; public static string SQL_NULL_DATE_8="00000000"; static Assembly _db2Assembly; @@ -523,7 +524,7 @@ sealed internal class Db2ConnectionWrapper : GxAbstractConnectionWrapper private static int changeConnState=-1; private static int changeConnStateExecuting = -1; private int openDataReaders; - static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); public Db2ConnectionWrapper() { try diff --git a/dotnet/src/dotnetframework/GxClasses/Data/GXDataDb2400.cs b/dotnet/src/dotnetframework/GxClasses/Data/GXDataDb2400.cs index 263f83260..6c2b40478 100644 --- a/dotnet/src/dotnetframework/GxClasses/Data/GXDataDb2400.cs +++ b/dotnet/src/dotnetframework/GxClasses/Data/GXDataDb2400.cs @@ -45,7 +45,7 @@ public override object GetValue(int i) } sealed internal class Db2ISeriesConnectionWrapper : GxAbstractConnectionWrapper { - static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); public Db2ISeriesConnectionWrapper() { try @@ -121,7 +121,7 @@ public override DbDataAdapter CreateDataAdapter() public class GxDb2ISeries : GxDataRecord { - static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); private bool m_UseCharInDate; public static string SQL_NULL_DATE="00000000"; private string m_InitialCatalog; @@ -768,7 +768,7 @@ public override string ToDbmsConstant(DateTime Value) } sealed internal class Db2ISeriesHISConnectionWrapper : GxAbstractConnectionWrapper { - static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); public Db2ISeriesHISConnectionWrapper() : base(new MsDb2Connection()) { } @@ -827,7 +827,7 @@ public override DbDataAdapter CreateDataAdapter() public class GxISeriesHIS : GxDataRecord { - static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); private bool m_UseCharInDate; private string m_InitialCatalog; private string m_SqlPackage; diff --git a/dotnet/src/dotnetframework/GxClasses/Data/GXDataHana.cs b/dotnet/src/dotnetframework/GxClasses/Data/GXDataHana.cs index 484449b3c..ad2cf1337 100644 --- a/dotnet/src/dotnetframework/GxClasses/Data/GXDataHana.cs +++ b/dotnet/src/dotnetframework/GxClasses/Data/GXDataHana.cs @@ -14,7 +14,7 @@ namespace GeneXus.Data { public class GxHana : GxDataRecord { - static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); static Assembly _hanaAssembly; const string HanaDbTypeEnum = "Sap.Data.Hana.HanaDbType"; #if NETCORE @@ -321,8 +321,8 @@ sealed internal class HanaConnectionWrapper : GxAbstractConnectionWrapper { const string HanaIsolationEnum = "Sap.Data.Hana.HanaIsolationLevel"; - static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - public HanaConnectionWrapper() + static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); + public HanaConnectionWrapper() { try { diff --git a/dotnet/src/dotnetframework/GxClasses/Data/GXDataInformix.cs b/dotnet/src/dotnetframework/GxClasses/Data/GXDataInformix.cs index 3c92389b9..6b326f74b 100644 --- a/dotnet/src/dotnetframework/GxClasses/Data/GXDataInformix.cs +++ b/dotnet/src/dotnetframework/GxClasses/Data/GXDataInformix.cs @@ -20,7 +20,7 @@ namespace GeneXus.Data { public class GxInformix : GxDataRecord { - static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); static Assembly _ifxAssembly; #if NETCORE internal static string InformixAssemblyName = "Informix.Net.Core"; @@ -459,7 +459,7 @@ public override IDbCommand GetCachedCommand(IGxConnection con, string stmt) public class GxInformixDataReader : GxDataReader { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GxInformixDataReader)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public GxInformixDataReader(IGxConnectionManager connManager, GxDataRecord dr, IGxConnection connection, GxParameterCollection parameters, string stmt, int fetchSize, bool forFirst, int handle, bool cached, SlidingTime expiration, bool dynStmt) : base(connManager, dr, connection, parameters, stmt, fetchSize, forFirst, handle, cached, expiration, dynStmt) @@ -586,7 +586,7 @@ sealed internal class InformixConnectionWrapper : GxAbstractConnectionWrapper { private static int changeConnState = -1; private int openDataReaders; - static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); public InformixConnectionWrapper() { try diff --git a/dotnet/src/dotnetframework/GxClasses/Data/GXDataMysqlConnector.cs b/dotnet/src/dotnetframework/GxClasses/Data/GXDataMysqlConnector.cs index 14ed3a8be..a9c2b8f98 100644 --- a/dotnet/src/dotnetframework/GxClasses/Data/GXDataMysqlConnector.cs +++ b/dotnet/src/dotnetframework/GxClasses/Data/GXDataMysqlConnector.cs @@ -23,7 +23,7 @@ namespace GeneXus.Data public class GxMySqlConnector : GxDataRecord { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Data.GxMySqlConnector)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private int MAX_TRIES; private int m_FailedConnections; #if NETCORE @@ -498,7 +498,9 @@ public override void SetParameter(IDbDataParameter parameter, object value) [SecuritySafeCritical] sealed internal class MySqlConnectorConnectionWrapper : GxAbstractConnectionWrapper { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Data.MySqlConnectorConnectionWrapper)); + + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + [SecuritySafeCritical] public MySqlConnectorConnectionWrapper() : base(new MySQLConnection()) { } @@ -566,7 +568,7 @@ public override short RollbackSavePoint(IDbTransaction transaction, string savep [SecuritySafeCritical] public class GxMySQLConnectorDataReader : GxDataReader { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GxMySQLConnectorDataReader)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public GxMySQLConnectorDataReader(IGxConnectionManager connManager, GxDataRecord dr, IGxConnection connection, GxParameterCollection parameters, string stmt, int fetchSize, bool forFirst, int handle, bool cached, SlidingTime expiration, bool dynStmt) { @@ -618,8 +620,7 @@ public override string GetString(int i) [SecuritySafeCritical] public class GxMySQLConnectorCursorDataReader : GxDataReader { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Data.GxDataReader)); - + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public GxMySQLConnectorCursorDataReader(IGxConnectionManager connManager, GxDataRecord dr, IGxConnection connection, GxParameterCollection parameters, string stmt, int fetchSize, bool forFirst, int handle, bool cached, SlidingTime expiration, bool hasNested, bool dynStmt) { diff --git a/dotnet/src/dotnetframework/GxClasses/Data/GXDataMysqlDriverCS.cs b/dotnet/src/dotnetframework/GxClasses/Data/GXDataMysqlDriverCS.cs index 54fb262e4..d6b9fe1e6 100644 --- a/dotnet/src/dotnetframework/GxClasses/Data/GXDataMysqlDriverCS.cs +++ b/dotnet/src/dotnetframework/GxClasses/Data/GXDataMysqlDriverCS.cs @@ -12,7 +12,8 @@ namespace GeneXus.Data { public class GxMySql : GxDataRecord { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Data.GxMySql)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + private int MAX_TRIES; private int m_FailedConnections; private bool preparedStmts; @@ -403,7 +404,7 @@ public override void SetParameter(IDbDataParameter parameter, object value) sealed internal class MySqlDriverCSConnectionWrapper : GxAbstractConnectionWrapper { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Data.MySqlDriverCSConnectionWrapper)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public MySqlDriverCSConnectionWrapper() : base(new MySQLConnection()) { } @@ -516,7 +517,7 @@ public override string GetString(int i) } public class GxMySQLDriverCSCursorDataReader : GxDataReader { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Data.GxDataReader)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public GxMySQLDriverCSCursorDataReader(IGxConnectionManager connManager, GxDataRecord dr, IGxConnection connection, GxParameterCollection parameters, string stmt, int fetchSize, bool forFirst, int handle, bool cached, SlidingTime expiration, bool hasNested, bool dynStmt) diff --git a/dotnet/src/dotnetframework/GxClasses/Data/GXDataNTier.cs b/dotnet/src/dotnetframework/GxClasses/Data/GXDataNTier.cs index 467cb2b4f..daad9651e 100644 --- a/dotnet/src/dotnetframework/GxClasses/Data/GXDataNTier.cs +++ b/dotnet/src/dotnetframework/GxClasses/Data/GXDataNTier.cs @@ -142,7 +142,7 @@ public interface IDataStoreHelper public class DataStoreHelperBase { /*DO NOT ADD INSTANCE VARIABLES IN THIS CLASS, THIS IS REFERENCED BY THE STATIC CURSORDEF ARRAY IN THE XX___DEFAULT, ALL THE VARIABLES HERE LIVE FOREVER*/ - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(DataStoreHelperBase)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private const string AND = " and "; private const string WHERE = " WHERE "; @@ -342,7 +342,8 @@ public interface IDataStoreProviderBase public class DataStoreProvider : IDataStoreProviderBase,IDataStoreProvider { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Data.NTier.DataStoreProvider)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + ICursor[] _cursor; Object[][] results; [System.Diagnostics.CodeAnalysis.SuppressMessage("GxFxCopRules", "CR1000:EnforceThreadSafeType")] diff --git a/dotnet/src/dotnetframework/GxClasses/Data/GXDataNTierADO.cs b/dotnet/src/dotnetframework/GxClasses/Data/GXDataNTierADO.cs index 5d2795af9..41022c95a 100644 --- a/dotnet/src/dotnetframework/GxClasses/Data/GXDataNTierADO.cs +++ b/dotnet/src/dotnetframework/GxClasses/Data/GXDataNTierADO.cs @@ -204,7 +204,7 @@ public IGeographicNative getGeospatial(int id) } public class GXFatFieldGetter : IFieldGetter { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Data.NTier.ADO.GXFatFieldGetter)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); IGxDbCommand _gxDbCommand; IDataReader _DR; public GXFatFieldGetter(GxCommand gxDbCommand) @@ -499,7 +499,7 @@ public bool wasNull(int id) } public class GXFatFieldSetter : IFieldSetter { - protected static readonly ILog log = log4net.LogManager.GetLogger(typeof(GXFatFieldSetter)); + protected static readonly IGXLogger log = GXLoggerFactory.GetLogger(); GxCommand _gxDbCommand; public GXFatFieldSetter(GxCommand gxDbCommand) { @@ -792,7 +792,7 @@ public void RestoreParametersRT() } public class Cursor : ICursor { - protected static readonly ILog log = log4net.LogManager.GetLogger(typeof(Cursor)); + protected static readonly IGXLogger log = GXLoggerFactory.GetLogger(); protected int _state = 0; protected string _name; protected string _stmt; diff --git a/dotnet/src/dotnetframework/GxClasses/Data/GXDataNTierService.cs b/dotnet/src/dotnetframework/GxClasses/Data/GXDataNTierService.cs index e29d0edb0..817de09bd 100644 --- a/dotnet/src/dotnetframework/GxClasses/Data/GXDataNTierService.cs +++ b/dotnet/src/dotnetframework/GxClasses/Data/GXDataNTierService.cs @@ -65,7 +65,7 @@ public ServiceCursorDef(string name, object query, GxErrorMask nmask, Object[] p public class GxServiceFactory { - protected static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + protected static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); public static GxService Create(string id, string providerId, string serviceClass) { @@ -75,7 +75,7 @@ public static GxService Create(string id, string providerId, string serviceClass public class GxService : GxDataRecord { - protected static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + protected static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); private Type m_ServiceType; private CursorDef m_CursorDef; @@ -316,8 +316,7 @@ public interface IServiceCommand sealed public class ServiceConnectionWrapper : GxAbstractConnectionWrapper { - static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - + static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); public ServiceConnectionWrapper(Type runtimeClassType, String connectionString, GxConnectionCache connCache, IsolationLevel isolationLevel, String dataSource) { try diff --git a/dotnet/src/dotnetframework/GxClasses/Data/GXDataOracle.cs b/dotnet/src/dotnetframework/GxClasses/Data/GXDataOracle.cs index 0e93a3efe..2cb65dc02 100644 --- a/dotnet/src/dotnetframework/GxClasses/Data/GXDataOracle.cs +++ b/dotnet/src/dotnetframework/GxClasses/Data/GXDataOracle.cs @@ -19,7 +19,7 @@ namespace GeneXus.Data { public class GxODPCacheDataReader : GxOracleCacheDataReader { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GxODPCacheDataReader)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public GxODPCacheDataReader(CacheItem cacheItem, bool computeSize, string keyCache) : base(cacheItem, computeSize, keyCache) { } @@ -116,7 +116,7 @@ public override bool IsDBNull(int i) } public class GxODPManagedCacheDataReader : GxOracleCacheDataReader { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GxODPManagedCacheDataReader)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public GxODPManagedCacheDataReader(CacheItem cacheItem, bool computeSize, string keyCache) : base(cacheItem, computeSize, keyCache) { } @@ -235,7 +235,7 @@ public override long GetBytes(int i, long fieldOffset, byte[] buffer, int buffer public class GxODPOracle : GxOracle { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GxODPOracle)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); static Assembly _odpAssembly; const string OracleDbTypeEnum = "Oracle.DataAccess.Client.OracleDbType"; @@ -547,7 +547,8 @@ internal static bool IsClobType(object value) } public class GxODPManagedOracle : GxOracle { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GxODPManagedOracle)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + static Assembly _odpAssembly; const string OracleDbTypeEnum = "Oracle.ManagedDataAccess.Client.OracleDbType"; const string OracleAssemblyName = "Oracle.ManagedDataAccess"; @@ -859,7 +860,7 @@ internal static bool IsClobType(object value) public class GxOracle : GxDataRecord { const string BLANK_STRING = " "; - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GxOracle)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); #if !NETCORE public override GxAbstractConnectionWrapper GetConnection(bool showPrompt, string datasourceName, string userId, string userPassword, string databaseName, string port, string schema, string extra, GxConnectionCache connectionCache) @@ -1304,7 +1305,7 @@ public override string ConcatOp(int pos) } public class GxODPOracleDataReader : GxDataReader { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GxODPOracleDataReader)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public GxODPOracleDataReader(IGxConnectionManager connManager, GxDataRecord dr, IGxConnection connection, GxParameterCollection parameters, string stmt, int fetchSize, bool forFirst, int handle, bool cached, SlidingTime expiration, bool dynStmt) : base(connManager, dr, connection, parameters, stmt, fetchSize, forFirst, handle, cached, expiration, dynStmt) @@ -1370,7 +1371,7 @@ public override decimal GetDecimal(int i) public class GxODPManagedOracleDataReader : GxDataReader { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GxODPManagedOracleDataReader)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public GxODPManagedOracleDataReader(IGxConnectionManager connManager, GxDataRecord dr, IGxConnection connection, GxParameterCollection parameters, string stmt, int fetchSize, bool forFirst, int handle, bool cached, SlidingTime expiration, bool dynStmt) : base(connManager, dr, connection, parameters, stmt, fetchSize, forFirst, handle, cached, expiration, dynStmt) @@ -1436,7 +1437,7 @@ public override decimal GetDecimal(int i) #if !NETCORE sealed internal class MSOracleConnectionWrapper : GxAbstractConnectionWrapper { - static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); int oracle8 = -1; public MSOracleConnectionWrapper() : base(new MSOracleProvider.OracleConnection()) { @@ -1531,7 +1532,7 @@ public override short RollbackSavePoint(IDbTransaction transaction, string savep #endif sealed internal class OracleConnectionWrapper : GxAbstractConnectionWrapper { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(OracleConnectionWrapper)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public OracleConnectionWrapper() { try @@ -1625,7 +1626,7 @@ public override short RollbackSavePoint(IDbTransaction transaction, string savep sealed internal class OracleManagedConnectionWrapper : GxAbstractConnectionWrapper { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(OracleManagedConnectionWrapper)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public OracleManagedConnectionWrapper() { try diff --git a/dotnet/src/dotnetframework/GxClasses/Data/GXDataPostgreSQL.cs b/dotnet/src/dotnetframework/GxClasses/Data/GXDataPostgreSQL.cs index b91c9e4cd..02dfcaeaa 100644 --- a/dotnet/src/dotnetframework/GxClasses/Data/GXDataPostgreSQL.cs +++ b/dotnet/src/dotnetframework/GxClasses/Data/GXDataPostgreSQL.cs @@ -20,7 +20,7 @@ namespace GeneXus.Data { public class GxPostgreSql : GxDataRecord { - static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); const string ConnectionStringEncoding = "encoding"; private byte[] _buffer; static Assembly _npgsqlAssembly; @@ -587,7 +587,7 @@ public override string ConcatOp(int pos) } sealed internal class PostgresqlConnectionWrapper : GxAbstractConnectionWrapper { - static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); public PostgresqlConnectionWrapper() { _connection = (IDbConnection)ClassLoader.CreateInstance(GxPostgreSql.NpgsqlAssembly, "Npgsql.NpgsqlConnection"); diff --git a/dotnet/src/dotnetframework/GxClasses/Data/GXDataSqlite.cs b/dotnet/src/dotnetframework/GxClasses/Data/GXDataSqlite.cs index 5d70d808f..6d84f06a8 100644 --- a/dotnet/src/dotnetframework/GxClasses/Data/GXDataSqlite.cs +++ b/dotnet/src/dotnetframework/GxClasses/Data/GXDataSqlite.cs @@ -19,7 +19,7 @@ namespace GeneXus.Data { public class GxSqlite : GxDataRecord { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Data.GxSqlite)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private int MAX_TRIES = 10; private int m_FailedConnections; @@ -310,8 +310,7 @@ public override void SetParameterBlob(IDbDataParameter parameter, string value, sealed internal class SQLiteConnectionWrapper : GxAbstractConnectionWrapper { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Data.SQLiteConnectionWrapper)); - + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public SQLiteConnectionWrapper() : base(new SQLiteConnection()) { } diff --git a/dotnet/src/dotnetframework/GxClasses/Diagnostics/GXDebugManager.cs b/dotnet/src/dotnetframework/GxClasses/Diagnostics/GXDebugManager.cs index 252c3caf3..0c1e9e2dc 100644 --- a/dotnet/src/dotnetframework/GxClasses/Diagnostics/GXDebugManager.cs +++ b/dotnet/src/dotnetframework/GxClasses/Diagnostics/GXDebugManager.cs @@ -20,7 +20,7 @@ public class GXDebugManager private static bool initialized; private static GXDebugManager m_Instance; - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Application.GxContext)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public static GXDebugManager Instance { get diff --git a/dotnet/src/dotnetframework/GxClasses/Diagnostics/Log.cs b/dotnet/src/dotnetframework/GxClasses/Diagnostics/Log.cs index 17ede87d5..f6433cf92 100644 --- a/dotnet/src/dotnetframework/GxClasses/Diagnostics/Log.cs +++ b/dotnet/src/dotnetframework/GxClasses/Diagnostics/Log.cs @@ -1,7 +1,10 @@ -using System; using GeneXus.Attributes; using GeneXus.Configuration; using log4net; +#if NETCORE +using GeneXus.Services.Log; +using Microsoft.Extensions.Logging; +#endif namespace GeneXus.Diagnostics { @@ -19,22 +22,28 @@ private enum LogLevel Fatal = 30 } #if NETCORE - static readonly string defaultRepository = LogManager.GetRepository(System.Reflection.Assembly.GetEntryAssembly()).Name; -#else - static readonly string defaultRepository = LogManager.GetRepository().Name; + public static ILoggerFactory _instance = GXLogService.GetLogFactory(); #endif - public static string defaultUserLogNamespace = Configuration.Config.GetValueOf("USER_LOG_NAMESPACE", LogConfiguration.USER_LOG_TOPIC); - - static readonly ILog globalLog = LogManager.GetLogger(defaultRepository, defaultUserLogNamespace); - - private static ILog GetLogger(string topic) + + public static IGXLogger GetLogger(string topic) { - if (!String.IsNullOrEmpty(topic)) + string defaultUserLogNamespace = Configuration.Config.GetValueOf("USER_LOG_NAMESPACE", LogConfiguration.USER_LOG_TOPIC); + string loggerName = defaultUserLogNamespace; + if (!string.IsNullOrEmpty(topic)) { - string loggerName = topic.StartsWith("$") ? topic.Substring(1) : string.Format("{0}.{1}", defaultUserLogNamespace, topic.Trim()); - return LogManager.GetLogger(defaultRepository, loggerName); + loggerName = topic.StartsWith("$") ? topic.Substring(1) : string.Format("{0}.{1}", defaultUserLogNamespace, topic.Trim()); } - return globalLog; +#if NETCORE + if (_instance != null) + { + return new GXLoggerMsExtensions(_instance.CreateLogger(loggerName)); + } + string defaultRepository = LogManager.GetRepository(System.Reflection.Assembly.GetEntryAssembly()).Name; +#else + string defaultRepository = LogManager.GetRepository().Name; +#endif + return new GXLoggerLog4Net(log4net.LogManager.GetLogger(defaultRepository, loggerName)); + } public static void Write(int logLevel, string message, string topic) @@ -44,7 +53,7 @@ public static void Write(int logLevel, string message, string topic) public static void Write(string message, string topic, int logLevel) { - ILog log = GetLogger(topic); + IGXLogger log = GetLogger(topic); LogLevel logLvl = (LogLevel)logLevel; switch (logLvl) @@ -52,57 +61,63 @@ public static void Write(string message, string topic, int logLevel) case LogLevel.Off: break; case LogLevel.Trace: - log.Debug(message); + GXLogging.Trace(log, message); break; case LogLevel.Debug: - log.Debug(message); + GXLogging.Debug(log, message); break; case LogLevel.Info: - log.Info(message); + GXLogging.Info(log, message); break; case LogLevel.Warn: - log.Warn(message); + GXLogging.Warn(log, message); break; case LogLevel.Error: - log.Error(message); + GXLogging.Error(log, message); break; case LogLevel.Fatal: - log.Fatal(message); + GXLogging.Critical(log, message); break; default: - log.Debug(message); + GXLogging.Debug(log, message); break; } } public static void Write(string message, string topic = "") { - GetLogger(topic).Debug(message); + IGXLogger log = GetLogger(topic); + GXLogging.Debug(log, message); } public static void Fatal(string message, string topic = "") { - GetLogger(topic).Fatal(message); + IGXLogger log = GetLogger(topic); + GXLogging.Critical(log, message); } public static void Error(string message, string topic = "") { - GetLogger(topic).Error(message); + IGXLogger log = GetLogger(topic); + GXLogging.Error(log, message); } public static void Warning(string message, string topic = "") { - GetLogger(topic).Warn(message); + IGXLogger log = GetLogger(topic); + GXLogging.Warn(log, message); } public static void Info(string message, string topic = "") { - GetLogger(topic).Info(message); + IGXLogger log = GetLogger(topic); + GXLogging.Info(log, message); } public static void Debug(string message, string topic = "") { - GetLogger(topic).Debug(message); + IGXLogger log = GetLogger(topic); + GXLogging.Debug(log, message); } } } diff --git a/dotnet/src/dotnetframework/GxClasses/Dialog/IProcess.cs b/dotnet/src/dotnetframework/GxClasses/Dialog/IProcess.cs index 74b48f2f1..04265fe3a 100644 --- a/dotnet/src/dotnetframework/GxClasses/Dialog/IProcess.cs +++ b/dotnet/src/dotnetframework/GxClasses/Dialog/IProcess.cs @@ -18,7 +18,8 @@ public interface IProcessHelper } public class OSHelper { - protected static readonly ILog log = log4net.LogManager.GetLogger(typeof(OSHelper)); + protected static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + protected static string OsProviderAssembly = "GxClasses.Win"; protected static object syncRoot = new Object(); diff --git a/dotnet/src/dotnetframework/GxClasses/Domain/ExpressionEvaluator.cs b/dotnet/src/dotnetframework/GxClasses/Domain/ExpressionEvaluator.cs index b9dd259b3..5daede0bb 100644 --- a/dotnet/src/dotnetframework/GxClasses/Domain/ExpressionEvaluator.cs +++ b/dotnet/src/dotnetframework/GxClasses/Domain/ExpressionEvaluator.cs @@ -17,7 +17,7 @@ namespace GeneXus.Utils /// public class ExpressionEvaluator { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Utils.ExpressionEvaluator)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); internal IGxContext context; internal bool throwExceptions; diff --git a/dotnet/src/dotnetframework/GxClasses/Domain/GXFileIO.cs b/dotnet/src/dotnetframework/GxClasses/Domain/GXFileIO.cs index 5788c1d3e..09aeea02c 100644 --- a/dotnet/src/dotnetframework/GxClasses/Domain/GXFileIO.cs +++ b/dotnet/src/dotnetframework/GxClasses/Domain/GXFileIO.cs @@ -223,8 +223,9 @@ public void MoveTo(string desDirName) } public class GxFileInfo : IGxFileInfo { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GxFileInfo)); - private FileInfo _file; + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + + private FileInfo _file; private string _baseDirectory; public GxFileInfo(FileInfo file) @@ -654,7 +655,7 @@ public enum GxFileType public class GxFile { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GxFile)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); internal IGxFileInfo _file; string _baseDirectory; @@ -1574,7 +1575,7 @@ public void Close() public class GxDirectory { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GxDirectory)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); IGxDirectoryInfo _directory; string _baseDirectory; int _lastError; diff --git a/dotnet/src/dotnetframework/GxClasses/Domain/GXGeolocation.cs b/dotnet/src/dotnetframework/GxClasses/Domain/GXGeolocation.cs index 6dff7a7de..9998431c6 100644 --- a/dotnet/src/dotnetframework/GxClasses/Domain/GXGeolocation.cs +++ b/dotnet/src/dotnetframework/GxClasses/Domain/GXGeolocation.cs @@ -19,7 +19,7 @@ namespace GX public class GXGeolocation { private const String MAPS_URI = "https://maps.google.com/maps/api/"; - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GX.GXGeolocation)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private static double GetComponent(String geolocation, int item) { diff --git a/dotnet/src/dotnetframework/GxClasses/Domain/GXLDAP.cs b/dotnet/src/dotnetframework/GxClasses/Domain/GXLDAP.cs index da79ac358..0ef849ae7 100644 --- a/dotnet/src/dotnetframework/GxClasses/Domain/GXLDAP.cs +++ b/dotnet/src/dotnetframework/GxClasses/Domain/GXLDAP.cs @@ -11,7 +11,7 @@ namespace GeneXus.Utils { public class GXLDAPClient { - static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); string _server; int _port; diff --git a/dotnet/src/dotnetframework/GxClasses/Domain/GXXmlReadWrite.cs b/dotnet/src/dotnetframework/GxClasses/Domain/GXXmlReadWrite.cs index f18f4a708..f34142d60 100644 --- a/dotnet/src/dotnetframework/GxClasses/Domain/GXXmlReadWrite.cs +++ b/dotnet/src/dotnetframework/GxClasses/Domain/GXXmlReadWrite.cs @@ -1898,7 +1898,7 @@ public void Dispose() public class GXXMLWriter: IDisposable { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GXXMLWriter)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private XmlTextWriter writer; private short errorCode; diff --git a/dotnet/src/dotnetframework/GxClasses/Domain/GxCollections.cs b/dotnet/src/dotnetframework/GxClasses/Domain/GxCollections.cs index 6da308291..db5be16f6 100644 --- a/dotnet/src/dotnetframework/GxClasses/Domain/GxCollections.cs +++ b/dotnet/src/dotnetframework/GxClasses/Domain/GxCollections.cs @@ -798,8 +798,8 @@ public void FromStringCollection(GxSimpleCollection value) public class GxObjectCollectionBase : GxSimpleCollection { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Utils.GxObjectCollectionBase)); - + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + public string _containedName; public string _containedXmlNamespace; public string _containedType; @@ -1038,7 +1038,7 @@ public string Name [XmlType(IncludeInSchema = false)] public class GxUserType : IGxXMLSerializable, ICloneable, IGxJSONAble, IGxJSONSerializable, IGXAssigned { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Utils.GxUserType)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); protected GXProperties dirties = new GXProperties(); static object setupChannelObject = null; diff --git a/dotnet/src/dotnetframework/GxClasses/Domain/GxGenericCollections.cs b/dotnet/src/dotnetframework/GxClasses/Domain/GxGenericCollections.cs index 9acc4c5b0..5e7d1974e 100644 --- a/dotnet/src/dotnetframework/GxClasses/Domain/GxGenericCollections.cs +++ b/dotnet/src/dotnetframework/GxClasses/Domain/GxGenericCollections.cs @@ -50,7 +50,7 @@ public GXBaseList() public class GXBaseCollection : GXBaseList, IGxXMLSerializable, IGxJSONAble, IGxCollection, IGxJSONSerializable where T : GxUserType, IGxXMLSerializable, IGxJSONAble, new() { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Utils.GXBaseCollection)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger>(); public string _containedName; public string _containedXmlNamespace; public IGxContext context; @@ -619,7 +619,7 @@ public override void RemoveItem(int idx) [Serializable] public class GXBCCollection : GXBaseCollection, IGXBCCollection where T : GxSilentTrnSdt, new() { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Utils.GXBCCollection)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger>(); public GXBCCollection() : base() { } public GXBCCollection(IGxContext context, diff --git a/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs b/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs index debd2d04b..c7505f675 100644 --- a/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs +++ b/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs @@ -58,7 +58,7 @@ internal MultiPartTemplate() } public class GxHttpClient : IGxHttpClient, IDisposable { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Http.Client.GxHttpClient)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public const int _Basic = 0; public const int _Digest = 1; public const int _NTLM = 2; diff --git a/dotnet/src/dotnetframework/GxClasses/Domain/GxMessaging.cs b/dotnet/src/dotnetframework/GxClasses/Domain/GxMessaging.cs index 75594364c..5d5fd17b5 100644 --- a/dotnet/src/dotnetframework/GxClasses/Domain/GxMessaging.cs +++ b/dotnet/src/dotnetframework/GxClasses/Domain/GxMessaging.cs @@ -16,7 +16,8 @@ namespace GeneXus.Utils [SecuritySafeCritical] public class GxQueueMessage { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Utils.GxQueueMessage)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + int priority; Message message; @@ -207,7 +208,7 @@ public bool canAddMSMQPropertiesToGet( MessagePropertyFilter m, string key, stri [SecuritySafeCritical] public class GxQueue { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GxQueue)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); string provider; string user; diff --git a/dotnet/src/dotnetframework/GxClasses/Domain/GxSession.cs b/dotnet/src/dotnetframework/GxClasses/Domain/GxSession.cs index d6c2ef005..46696c4b8 100644 --- a/dotnet/src/dotnetframework/GxClasses/Domain/GxSession.cs +++ b/dotnet/src/dotnetframework/GxClasses/Domain/GxSession.cs @@ -33,7 +33,7 @@ string Id public class GxWebSession : IGxSession { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Http.GxWebSession)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private HttpSessionState _httpSession; #region InternalKeys GXNavigationHelper InternalKeyNavigationHelper; diff --git a/dotnet/src/dotnetframework/GxClasses/Domain/SD/SDApis.cs b/dotnet/src/dotnetframework/GxClasses/Domain/SD/SDApis.cs index 363bd3eaf..fb6daed8f 100644 --- a/dotnet/src/dotnetframework/GxClasses/Domain/SD/SDApis.cs +++ b/dotnet/src/dotnetframework/GxClasses/Domain/SD/SDApis.cs @@ -11,9 +11,9 @@ namespace GX { public class ClientInformation { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GX.ClientInformation)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); - public static string AppVersionCode + public static string AppVersionCode { get { diff --git a/dotnet/src/dotnetframework/GxClasses/Helpers/GXFileWatcher.cs b/dotnet/src/dotnetframework/GxClasses/Helpers/GXFileWatcher.cs index 49cc89efe..6d91dac34 100644 --- a/dotnet/src/dotnetframework/GxClasses/Helpers/GXFileWatcher.cs +++ b/dotnet/src/dotnetframework/GxClasses/Helpers/GXFileWatcher.cs @@ -19,7 +19,7 @@ namespace GeneXus.Application public class GXFileWatcher : IDisposable { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GXFileWatcher)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private static volatile GXFileWatcher m_Instance; private static object m_SyncRoot = new Object(); TimeSpan TIMEOUT; diff --git a/dotnet/src/dotnetframework/GxClasses/Helpers/GXLogging.cs b/dotnet/src/dotnetframework/GxClasses/Helpers/GXLogging.cs index cde357552..21be83fc9 100644 --- a/dotnet/src/dotnetframework/GxClasses/Helpers/GXLogging.cs +++ b/dotnet/src/dotnetframework/GxClasses/Helpers/GXLogging.cs @@ -15,6 +15,16 @@ public class GXLoggerFactory #if NETCORE public static ILoggerFactory _instance = GXLogService.GetLogFactory(); #endif + public static IGXLogger GetLogger(string categoryName) + { +#if NETCORE + if (_instance != null) + { + return new GXLoggerMsExtensions(_instance.CreateLogger(categoryName)); + } +#endif + return new GXLoggerLog4Net(log4net.LogManager.GetLogger(categoryName)); + } public static IGXLogger GetLogger() where T : class { #if NETCORE @@ -29,115 +39,180 @@ public static IGXLogger GetLogger() where T : class } public interface IGXLogger { - bool IsTraceEnabled(); - bool IsErrorEnabled(); - bool IsWarningEnabled(); - bool IsDebugEnabled(); - bool IsInfoEnabled(); + bool IsTraceEnabled { get; } + bool IsErrorEnabled { get; } + bool IsWarningEnabled { get; } + bool IsDebugEnabled { get; } + bool IsInfoEnabled { get; } + bool IsCriticalEnabled { get; } + + bool TraceEnabled(); + bool CriticalEnabled(); + bool ErrorEnabled(); + bool WarningEnabled(); + bool DebugEnabled(); + bool InfoEnabled(); + + void LogTrace(string value); void LogError(string msg, Exception ex); void LogError(string msg); + void LogError(string msg, params string[] list); void LogWarning(Exception ex, string msg); void LogWarning(string msg); + void LogWarning(string msg, params string[] list); void LogDebug(string msg); void LogDebug(Exception ex, string msg); + void LogDebug(string msg, params string[] list); void LogInfo(string msg); + void LogInfo(string msg, params string[] list); + void LogCritical(string msg); + void LogCritical(Exception ex , string msg); + void LogCritical(string msg, params string[] list); } #if NETCORE internal class GXLoggerMsExtensions : IGXLogger { + internal Microsoft.Extensions.Logging.ILogger log { get; set; } internal GXLoggerMsExtensions(Microsoft.Extensions.Logging.ILogger logInstance) { log = logInstance; } - internal Microsoft.Extensions.Logging.ILogger log { get; set; } - public bool IsTraceEnabled() + + public bool IsTraceEnabled { get => TraceEnabled(); } + public bool IsErrorEnabled { get => ErrorEnabled(); } + public bool IsWarningEnabled { get => WarningEnabled(); } + public bool IsDebugEnabled { get => DebugEnabled(); } + public bool IsInfoEnabled { get => InfoEnabled(); } + public bool IsCriticalEnabled { get => CriticalEnabled(); } + public bool TraceEnabled() { return log.IsEnabled(LogLevel.Trace); } - public bool IsErrorEnabled() + public bool ErrorEnabled() { return log.IsEnabled(LogLevel.Error); } - public bool IsWarningEnabled() + public bool WarningEnabled() { return log.IsEnabled(LogLevel.Warning); } - public bool IsDebugEnabled() + public bool DebugEnabled() { return log.IsEnabled(LogLevel.Debug); } - public bool IsInfoEnabled() + public bool InfoEnabled() { return log.IsEnabled(LogLevel.Information); } - public void LogTrace(string value) + public bool CriticalEnabled() + { + return log.IsEnabled(LogLevel.Critical); + } + public void LogTrace(string msg) { - log.LogTrace(value); + log.LogTrace(msg); } public void LogError(string msg, Exception ex) { - log.LogError(msg, ex); + log.LogError(ex, msg); } public void LogError(string msg) { log.LogError(msg); } + public void LogError(string msg, params string[] list) + { + log.LogError(msg, list); + } public void LogWarning(Exception ex, string msg) { - log.LogWarning(msg, ex); + log.LogWarning(ex, msg); } public void LogWarning(string msg) { log.LogWarning(msg); } + public void LogWarning(string msg, params string[] list) + { + log.LogWarning(msg, list); + } public void LogDebug(string msg) { log.LogDebug(msg); } - + public void LogDebug(string msg, params string[] list) + { + log.LogDebug(msg, list); + } public void LogDebug(Exception ex, string msg) { - log.LogDebug(msg, ex); + log.LogDebug(ex, msg); } public void LogInfo(string msg) { log.LogInformation(msg); } + + public void LogInfo(string msg, params string[] list) + { + log.LogInformation(msg, list); + } + public void LogCritical(string msg) + { + log.LogCritical(msg); + } + public void LogCritical(Exception ex, string msg) + { + log.LogCritical(ex, msg); + } + public void LogCritical(string msg, params string[] list) + { + log.LogCritical(msg, list); + } } #endif - internal class GXLoggerLog4Net:IGXLogger + internal class GXLoggerLog4Net : IGXLogger { - internal ILog log { get; set; } internal GXLoggerLog4Net(ILog logInstance) { log = logInstance; } - public bool IsTraceEnabled() + public bool IsTraceEnabled { get => TraceEnabled(); } + public bool IsErrorEnabled { get => ErrorEnabled(); } + public bool IsWarningEnabled { get => WarningEnabled(); } + public bool IsDebugEnabled { get => DebugEnabled(); } + public bool IsInfoEnabled { get => InfoEnabled(); } + public bool IsCriticalEnabled { get => CriticalEnabled(); } + public bool TraceEnabled() { return log.Logger.IsEnabledFor(Level.Trace); } - public bool IsErrorEnabled() + public bool ErrorEnabled() { return log.IsErrorEnabled; } - public bool IsWarningEnabled() + public bool WarningEnabled() { return log.IsWarnEnabled; } - public bool IsDebugEnabled() + public bool DebugEnabled() { return log.IsDebugEnabled; } - public bool IsInfoEnabled() + public bool InfoEnabled() { return log.IsInfoEnabled; } + public bool CriticalEnabled() + { + return log.IsFatalEnabled; + } public void LogTrace(string value) { @@ -151,6 +226,17 @@ public void LogError(string msg) { log.Error(msg); } + public void LogError(string msg, params string[] list) + { + StringBuilder message = new StringBuilder(); + message.Append(msg); + foreach (string parm in list) + { + message.Append(parm); + } + + log.Error(message.ToString()); + } public void LogWarning(Exception ex, string msg) { log.Warn(msg, ex); @@ -159,6 +245,17 @@ public void LogWarning(string msg) { log.Warn(msg); } + public void LogWarning(string msg, params string[] list) + { + StringBuilder message = new StringBuilder(); + message.Append(msg); + foreach (string parm in list) + { + message.Append(parm); + } + + log.Warn(message.ToString()); + } public void LogDebug(string msg) { log.Debug(msg); @@ -168,14 +265,58 @@ public void LogDebug(Exception ex, string msg) { log.Debug(msg, ex); } + public void LogDebug(string msg, params string[] list) + { + StringBuilder message = new StringBuilder(); + message.Append(msg); + foreach (string parm in list) + { + message.Append(parm); + } + + log.Debug(message.ToString()); + } public void LogInfo(string msg) { log.Info(msg); } + public void LogInfo(string msg, params string[] list) + { + StringBuilder message = new StringBuilder(); + message.Append(msg); + foreach (string parm in list) + { + message.Append(parm); + } + log.Info(message.ToString()); + } + + public void LogCritical(string msg) + { + log.Fatal(msg); + } + public void LogCritical(Exception ex, string msg) + { + log.Fatal(msg, ex); + } + + public void LogCritical(string msg, params string[] list) + { + StringBuilder message = new StringBuilder(); + message.Append(msg); + foreach (string parm in list) + { + message.Append(parm); + } + + log.Fatal(message.ToString()); + } } public static class GXLogging { + #region log4NET + // Legacy // public static void Trace(this ILog log, params string[] list) { if (log.Logger.IsEnabledFor(Level.Trace)) @@ -183,11 +324,6 @@ public static void Trace(this ILog log, params string[] list) log.Logger.Log(MethodBase.GetCurrentMethod().DeclaringType, Level.Trace, string.Join(" ", list), null); } } - internal static void Trace(IGXLogger logger, params string[] list) - { - if (logger.IsTraceEnabled()) - logger.LogTrace(string.Join(" ", list)); - } public static void Error(ILog log, string msg, Exception ex) { if (log.IsErrorEnabled) @@ -195,15 +331,6 @@ public static void Error(ILog log, string msg, Exception ex) log.Error(msg, ex); } } - - internal static void Error(IGXLogger logger, string msg, Exception ex) - { - if (logger.IsErrorEnabled()) - { - logger.LogError(msg, ex); - } - } - public static void ErrorSanitized(ILog log, string msg, Exception ex) { if (log.IsErrorEnabled) @@ -211,24 +338,10 @@ public static void ErrorSanitized(ILog log, string msg, Exception ex) log.Error(Utils.StringUtil.Sanitize(msg, Utils.StringUtil.LogUserEntryWhiteList), ex); } } - - internal static void ErrorSanitized(IGXLogger logger, string msg, Exception ex) - { - if (logger.IsErrorEnabled()) - { - logger.LogError(Utils.StringUtil.Sanitize(msg, Utils.StringUtil.LogUserEntryWhiteList), ex); - } - } - public static void Error(ILog log, string msg1, string msg2, Exception ex) { Error(log, msg1 + msg2, ex); } - - internal static void Error(IGXLogger logger, string msg1, string msg2, Exception ex) - { - Error(logger, msg1 + msg2, ex); - } public static void Error(ILog log, Exception ex, params string[] list) { if (log.IsErrorEnabled) @@ -239,26 +352,10 @@ public static void Error(ILog log, Exception ex, params string[] list) } } } - internal static void Error(IGXLogger logger, Exception ex, params string[] list) - { - if (logger.IsErrorEnabled()) - { - foreach (string parm in list) - { - logger.LogError(parm); - } - } - } public static void Error(ILog log, params string[] list) { Error(log, null, list); } - - internal static void Error(IGXLogger logger, params string[] list) - { - Error(logger, null, list); - } - public static void Warn(ILog log, Exception ex, params string[] list) { if (log.IsWarnEnabled) @@ -274,32 +371,10 @@ public static void Warn(ILog log, Exception ex, params string[] list) log.Warn(msg); } } - - public static void Warn(IGXLogger logger, Exception ex, params string[] list) - { - if (logger.IsWarningEnabled()) - { - StringBuilder msg = new StringBuilder(); - foreach (string parm in list) - { - msg.Append(parm); - } - if (ex != null) - logger.LogWarning(ex, msg.ToString()); - else - logger.LogWarning(msg.ToString()); - } - } public static void Warn(ILog log, params string[] list) { Warn(log, null, list); } - - public static void Warn(IGXLogger logger, params string[] list) - { - Warn(logger, null, list); - } - public static void Warn(ILog log, string msg, Exception ex) { if (log.IsWarnEnabled) @@ -307,13 +382,25 @@ public static void Warn(ILog log, string msg, Exception ex) log.Warn(msg, ex); } } - internal static void Warn(IGXLogger logger, string msg, Exception ex) + public static void DebugSanitized(ILog log, Exception ex, params string[] list) { - if (logger.IsWarningEnabled()) + if (log.IsDebugEnabled) { - logger.LogWarning(ex, msg); + StringBuilder msg = new StringBuilder(); + foreach (string parm in list) + { + msg.Append(Utils.StringUtil.Sanitize(parm, Utils.StringUtil.LogUserEntryWhiteList)); + } + if (ex != null) + log.Debug(msg, ex); + else + log.Debug(msg); } } + public static void Debug(ILog log, params string[] list) + { + Debug(log, null, list); + } public static void Debug(ILog log, Exception ex, params string[] list) { if (log.IsDebugEnabled) @@ -329,122 +416,318 @@ public static void Debug(ILog log, Exception ex, params string[] list) log.Debug(msg); } } - public static void Debug(IGXLogger logger, Exception ex, params string[] list) + public static void DebugSanitized(ILog log, params string[] list) + { + DebugSanitized(log, null, list); + } + + public static void Debug(ILog log, string startMsg, Func buildMsg) + { + if (log.IsDebugEnabled) + { + string msg = buildMsg(); + log.Debug(startMsg + msg); + } + } + public static void Debug(ILog log, string msg1, string msg2, Exception ex) + { + Debug(log, msg1 + msg2, ex); + } + public static void Debug(ILog log, string msg, Exception ex) + { + if (log.IsDebugEnabled) + { + log.Debug(msg, ex); + } + } + public static void Info(ILog log, params string[] list) { - if (logger.IsDebugEnabled()) + if (log.IsInfoEnabled) { StringBuilder msg = new StringBuilder(); foreach (string parm in list) { msg.Append(parm); } - if (ex != null) - logger.LogDebug(ex, msg.ToString()); - else - logger.LogDebug(msg.ToString()); + log.Info(msg); } } + #endregion - public static void DebugSanitized(ILog log, Exception ex, params string[] list) + #region Microsoft.Extensions + internal static void Trace(IGXLogger logger, params string[] list) { - if (log.IsDebugEnabled) + if (logger != null) { - StringBuilder msg = new StringBuilder(); - foreach (string parm in list) + if (logger.IsTraceEnabled) + logger.LogTrace(string.Join(" ", list)); + } + } + public static void Critical(IGXLogger logger, params string[] list) + { + if (logger != null) + { + if (logger.IsCriticalEnabled) { - msg.Append(Utils.StringUtil.Sanitize(parm, Utils.StringUtil.LogUserEntryWhiteList)); + logger.LogCritical(string.Join(" ", list)); + } + } + } + public static void Critical(IGXLogger logger, string msg, Exception ex) + { + if (logger != null) + { + if (logger.IsCriticalEnabled) + { + logger.LogCritical(ex, msg); + } + } + } + public static void Critical(IGXLogger logger, string msg, params string[] list) + { + if (logger != null) + { + if (logger.IsCriticalEnabled) + { + logger.LogCritical(msg, list); } - if (ex != null) - log.Debug(msg, ex); - else - log.Debug(msg); } } - internal static void DebugSanitized(IGXLogger logger, Exception ex, params string[] list) + public static void Error(IGXLogger logger, string msg, Exception ex) { - if (logger.IsDebugEnabled()) + if (logger != null) { - StringBuilder msg = new StringBuilder(); - foreach (string parm in list) + if (logger.IsErrorEnabled) { - msg.Append(Utils.StringUtil.Sanitize(parm, Utils.StringUtil.LogUserEntryWhiteList)); + logger.LogError(msg, ex); + } + } + } + public static void Error(IGXLogger logger, string msg, params string[] list ) + { + if (logger != null) + { + if (logger.IsErrorEnabled) + { + logger.LogError(msg, list); } - if (ex != null) - logger.LogDebug(ex, msg.ToString()); - else - logger.LogDebug(msg.ToString()); } } - public static void Debug(ILog log, params string[] list) + internal static void ErrorSanitized(IGXLogger logger, string msg, Exception ex) { - Debug(log, null, list); + if (logger != null) + { + if (logger.IsErrorEnabled) + { + logger.LogError(Utils.StringUtil.Sanitize(msg, Utils.StringUtil.LogUserEntryWhiteList), ex); + } + } } - public static void Debug(IGXLogger logger, params string[] list) + internal static void Error(IGXLogger logger, string msg1, string msg2, Exception ex) + { + Error(logger, msg1 + msg2, ex); + } + + internal static void Error(IGXLogger logger, Exception ex, params string[] list) { - Debug(logger, null, list); + if (logger != null) + { + if (logger.IsErrorEnabled) + { + logger.LogError(ex.Message); + foreach (string parm in list) + { + logger.LogError(parm); + } + } + } } + internal static void Error(IGXLogger logger, params string[] list) + { + if (logger != null) + { + if (logger.IsErrorEnabled) + { + foreach (string parm in list) + { + logger.LogError(parm); + } + } + } + } + public static void Warn(IGXLogger logger, Exception ex, params string[] list) + { + if (logger != null) + { + if (logger.IsWarningEnabled) + { + StringBuilder msg = new StringBuilder(); + foreach (string parm in list) + { + msg.Append(parm); + } + if (ex != null) + logger.LogWarning(ex, msg.ToString()); + else + logger.LogWarning(msg.ToString()); + } + } + } + public static void Warn(IGXLogger logger, params string[] list) + { + if (logger != null) + { + if (logger.IsWarningEnabled) + { + StringBuilder msg = new StringBuilder(); + foreach (string parm in list) + { + msg.Append(parm); + } - public static void DebugSanitized(ILog log, params string[] list) + logger.LogWarning(msg.ToString()); + } + } + } + public static void Warn(IGXLogger logger, string msg, params string[] list) { - DebugSanitized(log, null, list); + if (logger != null) + { + if (logger.IsWarningEnabled) + { + logger.LogWarning(msg, list); + } + } + } + public static void Warn(IGXLogger logger, string msg, Exception ex) + { + if (logger != null) + { + if (logger.IsWarningEnabled) + { + logger.LogWarning(ex, msg); + } + } + } + internal static void DebugSanitized(IGXLogger logger, Exception ex, params string[] list) + { + if (logger != null) + { + if (logger.IsDebugEnabled) + { + StringBuilder msg = new StringBuilder(); + foreach (string parm in list) + { + msg.Append(Utils.StringUtil.Sanitize(parm, Utils.StringUtil.LogUserEntryWhiteList)); + } + if (ex != null) + logger.LogDebug(ex, msg.ToString()); + else + logger.LogDebug(msg.ToString()); + } + } } internal static void DebugSanitized(IGXLogger logger, params string[] list) { DebugSanitized(logger, null, list); } - - public static void Debug(ILog log, string startMsg, Func buildMsg) + public static void Debug(IGXLogger logger, Exception ex, params string[] list) { - if (log.IsDebugEnabled) + if (logger != null) { - string msg = buildMsg(); - log.Debug(startMsg + msg); + if (logger.IsDebugEnabled) + { + StringBuilder msg = new StringBuilder(); + foreach (string parm in list) + { + msg.Append(parm); + } + if (ex != null) + logger.LogDebug(ex, msg.ToString()); + else + logger.LogDebug(msg.ToString()); + } } } - public static void Debug(ILog log, string msg1, string msg2, Exception ex) + public static void Debug(IGXLogger logger, params string[] list) { - Debug(log, msg1 + msg2, ex); + if (logger != null) + { + if (logger.IsDebugEnabled) + { + StringBuilder msg = new StringBuilder(); + foreach (string parm in list) + { + msg.Append(parm); + } + + logger.LogDebug(msg.ToString()); + } + } } - public static void Debug(ILog log, string msg, Exception ex) + + public static void Debug(IGXLogger logger, string startMsg, Func buildMsg) { - if (log.IsDebugEnabled) + if (logger != null) { - log.Debug(msg, ex); + if (logger.IsDebugEnabled) + { + string msg = buildMsg(); + logger.LogDebug(startMsg + msg); + } } } - internal static void Debug(IGXLogger logger, string msg, Exception ex) + public static void Debug(IGXLogger logger, string msg1, string msg2, Exception ex) { - if (logger.IsDebugEnabled()) + Debug(logger, msg1 + msg2, ex); + } + public static void Debug(IGXLogger logger, string msg, params string[] list) + { + if (logger != null) { - logger.LogDebug(ex, msg); + if (logger.IsDebugEnabled) + { + logger.LogDebug(msg, list); + } } } - public static void Info(ILog log, params string[] list) + public static void Debug(IGXLogger logger, string msg, Exception ex) { - if (log.IsInfoEnabled) + if (logger != null) { - StringBuilder msg = new StringBuilder(); - foreach (string parm in list) + if (logger.IsDebugEnabled) { - msg.Append(parm); + logger.LogDebug(ex, msg); } - log.Info(msg); } } public static void Info(IGXLogger logger, params string[] list) { - if (logger.IsInfoEnabled()) + if (logger != null) { - StringBuilder msg = new StringBuilder(); - foreach (string parm in list) + if (logger.IsInfoEnabled) { - msg.Append(parm); + StringBuilder msg = new StringBuilder(); + foreach (string parm in list) + { + msg.Append(parm); + } + logger.LogInfo(msg.ToString()); + } + } + } + public static void Info(IGXLogger logger, string msg, params string[] list) + { + if (logger != null) { + if (logger.IsInfoEnabled) + { + logger.LogInfo(msg.ToString(), list); } - logger.LogInfo(msg.ToString()); } } + #endregion } } diff --git a/dotnet/src/dotnetframework/GxClasses/Helpers/GXMetadata.cs b/dotnet/src/dotnetframework/GxClasses/Helpers/GXMetadata.cs index 770cc499e..d35565569 100644 --- a/dotnet/src/dotnetframework/GxClasses/Helpers/GXMetadata.cs +++ b/dotnet/src/dotnetframework/GxClasses/Helpers/GXMetadata.cs @@ -18,7 +18,7 @@ namespace GeneXus.Metadata public class ClassLoader { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Metadata.ClassLoader)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); #if NETCORE private const string GXWEBPROCEDURE_TYPE = "GeneXus.Procedure.GXWebProcedure"; diff --git a/dotnet/src/dotnetframework/GxClasses/Helpers/GXRes.cs b/dotnet/src/dotnetframework/GxClasses/Helpers/GXRes.cs index 41967b215..0d275c426 100644 --- a/dotnet/src/dotnetframework/GxClasses/Helpers/GXRes.cs +++ b/dotnet/src/dotnetframework/GxClasses/Helpers/GXRes.cs @@ -20,7 +20,7 @@ namespace GeneXus.Resources public class GXResourceManager { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Resources.GXResourceManager)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); static ConcurrentDictionary _rm = new ConcurrentDictionary(); static ConcurrentDictionary _localUtils = new ConcurrentDictionary(); static string _defaultLangName; diff --git a/dotnet/src/dotnetframework/GxClasses/Helpers/GXRestUtils.cs b/dotnet/src/dotnetframework/GxClasses/Helpers/GXRestUtils.cs index da14c4012..c6ae7db51 100644 --- a/dotnet/src/dotnetframework/GxClasses/Helpers/GXRestUtils.cs +++ b/dotnet/src/dotnetframework/GxClasses/Helpers/GXRestUtils.cs @@ -96,7 +96,7 @@ public class UploadCachedFile internal class RestAPIHelpers { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Utils.RestAPIHelpers)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public static Dictionary ReadRestParameters(string restData) { diff --git a/dotnet/src/dotnetframework/GxClasses/Helpers/GXUtilsGeospatial.cs b/dotnet/src/dotnetframework/GxClasses/Helpers/GXUtilsGeospatial.cs index 259e61060..7d8c4e48c 100644 --- a/dotnet/src/dotnetframework/GxClasses/Helpers/GXUtilsGeospatial.cs +++ b/dotnet/src/dotnetframework/GxClasses/Helpers/GXUtilsGeospatial.cs @@ -33,7 +33,7 @@ int Srid class SQLGeographyWrapper { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Utils.SQLGeographyWrapper)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); static Assembly _geoAssembly; public const string SqlGeographyClass = "Microsoft.SqlServer.Types.SqlGeography"; public const string SqlGeometryClass = "Microsoft.SqlServer.Types.SqlGeometry"; @@ -152,7 +152,7 @@ internal static object STGeomFromText(string geoText, int sRID) [DataContract] public class Geospatial : IGeographicNative { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Utils.Geospatial)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); internal const string EMPTY_GEOMETRY = "GEOMETRYCOLLECTION EMPTY"; const string EMPTY_GEOGRAPHY = "GEOGRAPHY EMPTY"; diff --git a/dotnet/src/dotnetframework/GxClasses/Helpers/HttpHelper.cs b/dotnet/src/dotnetframework/GxClasses/Helpers/HttpHelper.cs index 4fd91c649..4acb20bb5 100644 --- a/dotnet/src/dotnetframework/GxClasses/Helpers/HttpHelper.cs +++ b/dotnet/src/dotnetframework/GxClasses/Helpers/HttpHelper.cs @@ -75,7 +75,7 @@ public class WrappedJsonError public class HttpHelper { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Http.HttpHelper)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); /* * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control * Specifying no-cache or max-age=0 indicates that diff --git a/dotnet/src/dotnetframework/GxClasses/Helpers/JSONHelper.cs b/dotnet/src/dotnetframework/GxClasses/Helpers/JSONHelper.cs index 663ff5a08..0d8d63ce2 100644 --- a/dotnet/src/dotnetframework/GxClasses/Helpers/JSONHelper.cs +++ b/dotnet/src/dotnetframework/GxClasses/Helpers/JSONHelper.cs @@ -137,7 +137,7 @@ internal static GXJsonSerializer Instance public class JSONHelper { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Utils.JSONHelper)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); static string WFCDateTimeFormat = Preferences.WFCDateTimeMillis ? DateTimeUtil.JsonDateFormatMillis : DateTimeUtil.JsonDateFormat; public static bool IsJsonNull(object jobject) { diff --git a/dotnet/src/dotnetframework/GxClasses/Helpers/ThemeHelper.cs b/dotnet/src/dotnetframework/GxClasses/Helpers/ThemeHelper.cs index c5111af43..b0cca8a92 100644 --- a/dotnet/src/dotnetframework/GxClasses/Helpers/ThemeHelper.cs +++ b/dotnet/src/dotnetframework/GxClasses/Helpers/ThemeHelper.cs @@ -10,7 +10,7 @@ namespace GeneXus.Helpers { public sealed class ThemeHelper { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Helpers.ThemeHelper)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private static ConcurrentDictionary m_themes = new ConcurrentDictionary(); private static ThemeData CreateDefaultThemeData(string themeName) { diff --git a/dotnet/src/dotnetframework/GxClasses/Management/GXManagement.cs b/dotnet/src/dotnetframework/GxClasses/Management/GXManagement.cs index ed9aa8d42..90f4fadec 100644 --- a/dotnet/src/dotnetframework/GxClasses/Management/GXManagement.cs +++ b/dotnet/src/dotnetframework/GxClasses/Management/GXManagement.cs @@ -345,7 +345,7 @@ string LastConnectionId [SecuritySafeCritical] public class WMIApplicationServer : IWMIApplicationServer { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(WMIApplicationServer)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private static WMIApplicationServer instance; private static object syncObj = new object(); public static WMIApplicationServer Instance() @@ -434,7 +434,8 @@ public void CleanUp() [SecuritySafeCritical] public class WMICache : IWMICache { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(WMICache)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + InProcessCache cache; Hashtable wmicacheItems; long maxCacheStorageSize; @@ -543,7 +544,7 @@ public void Remove(string key) [SecuritySafeCritical] public class WMICacheItem :IWMICacheItem { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(WMICacheItem)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); string stmt; ICacheItemExpiration itemExpiration; @@ -635,7 +636,7 @@ public void CleanUp() [SecuritySafeCritical] public class WMIConnection : IWMIConnection { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(WMIConnection)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); GxConnection connection; public WMIConnection(GxConnection connection) @@ -786,7 +787,7 @@ public void CleanUp() [SecuritySafeCritical] public class WMIDataSource : IWMIDataSource { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(WMIDataSource)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); GxDataStore dataSource; public WMIDataSource(GxDataStore dataSource) @@ -861,7 +862,7 @@ public void CleanUp() [SecuritySafeCritical] public class WMIServerUserInformation :IWMIServerUserInformation { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(WMIServerUserInformation)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); ServerUserInformation userInfo; string lastConnectionId; diff --git a/dotnet/src/dotnetframework/GxClasses/Management/GXPerformance.cs b/dotnet/src/dotnetframework/GxClasses/Management/GXPerformance.cs index 36d9d07c4..823738b4b 100644 --- a/dotnet/src/dotnetframework/GxClasses/Management/GXPerformance.cs +++ b/dotnet/src/dotnetframework/GxClasses/Management/GXPerformance.cs @@ -661,7 +661,7 @@ public void IncSentencesCount(ICursor cursor) [SecuritySafeCritical] public class WMIDataStoreProviders:WMIDataStoreProvidersBase { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(WMIDataStoreProviders)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private WMIDataStoreProviders() { @@ -735,7 +735,7 @@ public WMIDataStoreProvider(string datastoreName) : base() [SecuritySafeCritical] public class WMIDataStoreProviderBase { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(WMIDataStoreProviderBase)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private long statementCount; private long statementSelectCount; diff --git a/dotnet/src/dotnetframework/GxClasses/Middleware/GXHttp.cs b/dotnet/src/dotnetframework/GxClasses/Middleware/GXHttp.cs index 8877eb7e2..7e5cfe537 100644 --- a/dotnet/src/dotnetframework/GxClasses/Middleware/GXHttp.cs +++ b/dotnet/src/dotnetframework/GxClasses/Middleware/GXHttp.cs @@ -56,7 +56,8 @@ public abstract class GXHttpHandler : GXBaseObject, IHttpHandler public abstract class GXHttpHandler : WebControl, IHttpHandler #endif { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Http.GXHttpHandler)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + internal const string GX_AJAX_REQUEST_HEADER = "GxAjaxRequest"; internal const string GX_SPA_GXOBJECT_RESPONSE_HEADER = "X-GXOBJECT"; internal const string GX_SPA_MASTERPAGE_HEADER = "X-SPA-MP"; @@ -1837,7 +1838,7 @@ private bool ValidateObjectAccess(String cmpCtx) SendResponseStatus(HttpStatusCode.Unauthorized); if (context.GetBrowserType() != GxContext.BROWSER_INDEXBOT) { - if (log.IsWarnEnabled) + if (log.IsWarningEnabled) { GXLogging.Warn(log, $"Validation security token '{GetObjectAccessWebToken(cmpCtx)}' failed for program: '{cmpCtx + this.GetPgmname().ToUpper()}'"); } diff --git a/dotnet/src/dotnetframework/GxClasses/Middleware/GXHttpModules.cs b/dotnet/src/dotnetframework/GxClasses/Middleware/GXHttpModules.cs index 98ffd93e3..380d7a493 100644 --- a/dotnet/src/dotnetframework/GxClasses/Middleware/GXHttpModules.cs +++ b/dotnet/src/dotnetframework/GxClasses/Middleware/GXHttpModules.cs @@ -201,7 +201,7 @@ public void ServicesGroupSetting(string webPath) } public class GXSessionModule : IHttpModule { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GXSessionModule)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); HttpApplication App; const string ASPNETSESSION_COOKIE = "ASP.NET_SessionId"; string cookieName= ASPNETSESSION_COOKIE; @@ -306,7 +306,7 @@ void IHttpModule.Dispose() } public class GXRewriter : IHttpModule { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GXRewriter)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private static RewriterModule rewriter; private static bool moduleStarted; private static bool enabled; diff --git a/dotnet/src/dotnetframework/GxClasses/Middleware/GXHttpServices.cs b/dotnet/src/dotnetframework/GxClasses/Middleware/GXHttpServices.cs index 5d7ef1e35..6302a7946 100644 --- a/dotnet/src/dotnetframework/GxClasses/Middleware/GXHttpServices.cs +++ b/dotnet/src/dotnetframework/GxClasses/Middleware/GXHttpServices.cs @@ -34,6 +34,8 @@ namespace GeneXus.Http using System.Linq; using GeneXus.Procedure; using GxClasses.Web.Middleware; + using Microsoft.AspNetCore.Hosting; + #else using System.Web.UI; @@ -144,7 +146,8 @@ public override void webExecute() public class GXReorServices : GXHttpHandler { - static readonly ILog log = LogManager.GetLogger(typeof(GXReorServices)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + static Assembly _reorAssembly; static Assembly _gxDataInitializationAssembly; readonly string[] reorArgs = { "-force", "-ignoreresume", "-nogui", "-noverifydatabaseschema" }; @@ -570,7 +573,7 @@ protected override GAMSecurityLevel IntegratedSecurityLevel internal class GXOAuthAccessToken : GXHttpHandler, IRequiresSessionState { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Http.GXOAuthAccessToken)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public GXOAuthAccessToken() { diff --git a/dotnet/src/dotnetframework/GxClasses/Middleware/HandlerFactory.cs b/dotnet/src/dotnetframework/GxClasses/Middleware/HandlerFactory.cs index b945d0df5..5630c457e 100644 --- a/dotnet/src/dotnetframework/GxClasses/Middleware/HandlerFactory.cs +++ b/dotnet/src/dotnetframework/GxClasses/Middleware/HandlerFactory.cs @@ -56,7 +56,7 @@ public bool IsReusable } class HandlerFactory : IHttpHandlerFactory { - private static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); private static List GxNamespaces; public IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated) diff --git a/dotnet/src/dotnetframework/GxClasses/Model/GXBaseObject.cs b/dotnet/src/dotnetframework/GxClasses/Model/GXBaseObject.cs index 2f8ef622c..091060c9a 100644 --- a/dotnet/src/dotnetframework/GxClasses/Model/GXBaseObject.cs +++ b/dotnet/src/dotnetframework/GxClasses/Model/GXBaseObject.cs @@ -22,7 +22,8 @@ public class GxObjectParameter } public class GXBaseObject { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GXBaseObject)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + private Dictionary callTargetsByObject = new Dictionary(); protected IGxContext _Context; bool _isMain; diff --git a/dotnet/src/dotnetframework/GxClasses/Model/GXSilentTrn.cs b/dotnet/src/dotnetframework/GxClasses/Model/GXSilentTrn.cs index 371405266..3e585b002 100644 --- a/dotnet/src/dotnetframework/GxClasses/Model/GXSilentTrn.cs +++ b/dotnet/src/dotnetframework/GxClasses/Model/GXSilentTrn.cs @@ -138,7 +138,7 @@ public msglist GX_msglist [Serializable] public class GxSilentTrnSdt : GxUserType { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Utils.GxSilentTrnSdt)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public GxSilentTrnSdt(IGxContext context){ this.context = context; diff --git a/dotnet/src/dotnetframework/GxClasses/Model/GxMockProvider.cs b/dotnet/src/dotnetframework/GxClasses/Model/GxMockProvider.cs index 166a67064..5ed03425b 100644 --- a/dotnet/src/dotnetframework/GxClasses/Model/GxMockProvider.cs +++ b/dotnet/src/dotnetframework/GxClasses/Model/GxMockProvider.cs @@ -9,7 +9,7 @@ public interface IGxMock } public class GxMockProvider { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GxMockProvider)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private static volatile IGxMock provider; diff --git a/dotnet/src/dotnetframework/GxClasses/Model/gxproc.cs b/dotnet/src/dotnetframework/GxClasses/Model/gxproc.cs index 7ec76f78e..ec07be7b2 100644 --- a/dotnet/src/dotnetframework/GxClasses/Model/gxproc.cs +++ b/dotnet/src/dotnetframework/GxClasses/Model/gxproc.cs @@ -355,7 +355,7 @@ public class GxReportUtils public static int OUTPUT_RVIEWER_NATIVE = 1; public static int OUTPUT_RVIEWER_DLL = 2; public static int OUTPUT_PDF = 3; - static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); static public IReportHandler GetPrinter( int outputType, string path, Stream reportOutputStream) { diff --git a/dotnet/src/dotnetframework/GxClasses/Notifications/WebSocket/GXWebSocketFactory.cs b/dotnet/src/dotnetframework/GxClasses/Notifications/WebSocket/GXWebSocketFactory.cs index b35f4dc50..a0b36e7a8 100644 --- a/dotnet/src/dotnetframework/GxClasses/Notifications/WebSocket/GXWebSocketFactory.cs +++ b/dotnet/src/dotnetframework/GxClasses/Notifications/WebSocket/GXWebSocketFactory.cs @@ -6,9 +6,8 @@ namespace GeneXus.Notifications.WebSocket { public class GXWebSocketFactory { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GXWebSocketFactory)); - - public static IGXWebSocketAsync GetWebSocketProvider() + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + public static IGXWebSocketAsync GetWebSocketProvider() { IGXWebSocketAsync ws = null; try diff --git a/dotnet/src/dotnetframework/GxClasses/Printer/GxPrinter.cs b/dotnet/src/dotnetframework/GxClasses/Printer/GxPrinter.cs index 45b9b3989..760e2320d 100644 --- a/dotnet/src/dotnetframework/GxClasses/Printer/GxPrinter.cs +++ b/dotnet/src/dotnetframework/GxClasses/Printer/GxPrinter.cs @@ -1116,7 +1116,7 @@ float convertY( float y) } public class GxTxtPrinter : IPrintHandler { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GxTxtPrinter)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); StreamReader streamToRead; StreamWriter streamToWrite; List pageContents; diff --git a/dotnet/src/dotnetframework/GxClasses/Reorg/GXReorg.cs b/dotnet/src/dotnetframework/GxClasses/Reorg/GXReorg.cs index e2c0bba8f..77e35d8bb 100644 --- a/dotnet/src/dotnetframework/GxClasses/Reorg/GXReorg.cs +++ b/dotnet/src/dotnetframework/GxClasses/Reorg/GXReorg.cs @@ -31,7 +31,7 @@ public interface IReorgReader public class GXReorganization { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Reorg.GXReorganization)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public virtual void initialize() { } public virtual void cleanup() { } static ArrayList lstMsgs; diff --git a/dotnet/src/dotnetframework/GxClasses/Security/GxSecurityProvider.cs b/dotnet/src/dotnetframework/GxClasses/Security/GxSecurityProvider.cs index fc6d125bf..fbb85a241 100644 --- a/dotnet/src/dotnetframework/GxClasses/Security/GxSecurityProvider.cs +++ b/dotnet/src/dotnetframework/GxClasses/Security/GxSecurityProvider.cs @@ -35,7 +35,7 @@ public interface ISecurityProvider } public class GxSecurityProvider { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Security.GxSecurityProvider)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private static volatile ISecurityProvider provider; private static object syncRoot = new Object(); diff --git a/dotnet/src/dotnetframework/GxClasses/Security/WebSecurity.cs b/dotnet/src/dotnetframework/GxClasses/Security/WebSecurity.cs index 8199d0488..ab50dd078 100644 --- a/dotnet/src/dotnetframework/GxClasses/Security/WebSecurity.cs +++ b/dotnet/src/dotnetframework/GxClasses/Security/WebSecurity.cs @@ -1,8 +1,3 @@ -using GeneXus.Application; -using GeneXus.Configuration; -using GeneXus.Utils; -using log4net; -using Microsoft.IdentityModel.Tokens; using System; using System.IdentityModel.Tokens.Jwt; using System.Linq; @@ -10,6 +5,11 @@ using System.Security; using System.Security.Claims; using System.Text; +using GeneXus.Application; +using GeneXus.Configuration; +using GeneXus.Utils; +using log4net; +using Microsoft.IdentityModel.Tokens; using static GeneXus.Web.Security.SecureTokenHelper; namespace GeneXus.Web.Security @@ -17,7 +17,8 @@ namespace GeneXus.Web.Security [SecuritySafeCritical] public static class WebSecurityHelper { - private static readonly ILog _log = LogManager.GetLogger(typeof(GeneXus.Web.Security.WebSecurityHelper)); + static readonly IGXLogger _log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); + const int SecretKeyMinimumLength = 16; public static string StripInvalidChars(string input) @@ -111,9 +112,10 @@ internal static bool VerifySecureSignedSDTToken(string cmpCtx, GxUserType value, [SecuritySafeCritical] public static class SecureTokenHelper { - private static readonly ILog _log = LogManager.GetLogger(typeof(GeneXus.Web.Security.SecureTokenHelper)); + + static readonly IGXLogger _log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); - public enum SecurityMode + public enum SecurityMode { Sign, SignEncrypt, diff --git a/dotnet/src/dotnetframework/GxClasses/Services/Caching/GxCache.cs b/dotnet/src/dotnetframework/GxClasses/Services/Caching/GxCache.cs index d186d0d91..067547a46 100644 --- a/dotnet/src/dotnetframework/GxClasses/Services/Caching/GxCache.cs +++ b/dotnet/src/dotnetframework/GxClasses/Services/Caching/GxCache.cs @@ -95,8 +95,9 @@ public override void Write(Utf8JsonWriter writer, object value, JsonSerializerOp public class CacheFactory { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Cache.CacheFactory)); - public static string CACHE_SD = "SD"; + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + + public static string CACHE_SD = "SD"; public static string CACHE_DB = "DB"; public static string CACHE_FILES = "FL"; public static string FORCE_HIGHEST_TIME_TO_LIVE = "FORCE_HIGHEST_TIME_TO_LIVE"; @@ -175,7 +176,7 @@ public static bool ForceHighestTimetoLive } public sealed class InProcessCache : ICacheService2 { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Cache.InProcessCache)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); ICacheStorage cacheStorage; IScavengingAlgorithm storageScavengingImplementation; @@ -644,7 +645,7 @@ public interface ICacheStorage public class SingletonCacheStorage : ICacheStorage { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Cache.SingletonCacheStorage)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private HybridDictionary cacheStorage = new HybridDictionary(); private long size; @@ -715,8 +716,9 @@ void ICacheStorage.Update(string key, object keyData) public class LruScavenging : IScavengingAlgorithm { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Cache.LruScavenging)); - private HybridDictionary itemsLastUsed; + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + + private HybridDictionary itemsLastUsed; private ICacheService cachingService; private ICacheStorage cacheStorage; private ICacheMetadata cacheMetadata; diff --git a/dotnet/src/dotnetframework/GxClasses/Services/GXRestServices.cs b/dotnet/src/dotnetframework/GxClasses/Services/GXRestServices.cs index e13ebb200..0bacb7e92 100644 --- a/dotnet/src/dotnetframework/GxClasses/Services/GXRestServices.cs +++ b/dotnet/src/dotnetframework/GxClasses/Services/GXRestServices.cs @@ -107,7 +107,7 @@ internal class CorrelationState } class CustomOperationSelector : WebHttpDispatchOperationSelector { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(CustomOperationSelector)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public CustomOperationSelector(ServiceEndpoint endpoint) : base(endpoint) { } protected override string SelectOperation(ref Message message, out bool uriMatched) { @@ -231,7 +231,8 @@ public override object ConvertStringToValue(string parameter, Type parameterType } public class GxRestService : System.Web.SessionState.IRequiresSessionState { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GxRestService)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + internal const string WARNING_HEADER = "Warning"; protected IGxContext context; private HttpContext httpContext; diff --git a/dotnet/src/dotnetframework/GxClasses/Services/GxRestWrapper.cs b/dotnet/src/dotnetframework/GxClasses/Services/GxRestWrapper.cs index c0b1c6a74..873144353 100644 --- a/dotnet/src/dotnetframework/GxClasses/Services/GxRestWrapper.cs +++ b/dotnet/src/dotnetframework/GxClasses/Services/GxRestWrapper.cs @@ -51,7 +51,7 @@ public class GxRestWrapper public class GxRestWrapper : IHttpHandler, IRequiresSessionState #endif { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Application.GxRestWrapper)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); protected HttpContext _httpContext; protected IGxContext _gxContext; private GXBaseObject _procWorker; diff --git a/dotnet/src/dotnetframework/GxClasses/Services/Storage/ExternalProviderBase.cs b/dotnet/src/dotnetframework/GxClasses/Services/Storage/ExternalProviderBase.cs index 0a2a6dc20..6ce9055af 100644 --- a/dotnet/src/dotnetframework/GxClasses/Services/Storage/ExternalProviderBase.cs +++ b/dotnet/src/dotnetframework/GxClasses/Services/Storage/ExternalProviderBase.cs @@ -12,7 +12,7 @@ namespace GeneXus.Services { public abstract class ExternalProviderBase { - static readonly ILog logger = log4net.LogManager.GetLogger(typeof(ExternalProviderBase)); + static readonly IGXLogger logger = GXLoggerFactory.GetLogger(); private GXService service; @@ -41,7 +41,7 @@ public ExternalProviderBase(GXService s) s = ServiceFactory.GetGXServices()?.Get(GXServices.STORAGE_SERVICE); } catch (Exception) { - logger.Warn("STORAGE_SERVICE is not activated in CloudServices.config"); + GXLogging.Warn(logger, "STORAGE_SERVICE is not activated in CloudServices.config"); } } @@ -82,7 +82,7 @@ protected String GetEncryptedPropertyValue(String propertyName, String alternati if (value == null) { String errorMessage = String.Format($"Service configuration error - Property name {ResolvePropertyName(propertyName)} must be defined"); - logger.Fatal(errorMessage); + GXLogging.Critical(logger, errorMessage); throw new Exception(errorMessage); } return value; @@ -102,7 +102,7 @@ protected String GetEncryptedPropertyValue(String propertyName, String alternati } catch (Exception) { - logger.Warn($"Could not decrypt property name: {ResolvePropertyName(propertyName)}"); + GXLogging.Warn(logger, $"Could not decrypt property name: {ResolvePropertyName(propertyName)}"); } } return value; @@ -114,7 +114,7 @@ protected String GetPropertyValue(String propertyName, String alternativePropert if (value == null) { String errorMessage = String.Format($"Service configuration error - Property name {ResolvePropertyName(propertyName)} must be defined"); - logger.Fatal(errorMessage); + GXLogging.Critical(logger, errorMessage); throw new Exception(errorMessage); } return value; diff --git a/dotnet/src/dotnetframework/GxClasses/Services/Storage/GXServices.cs b/dotnet/src/dotnetframework/GxClasses/Services/Storage/GXServices.cs index 0c652ecf7..3b74e7794 100644 --- a/dotnet/src/dotnetframework/GxClasses/Services/Storage/GXServices.cs +++ b/dotnet/src/dotnetframework/GxClasses/Services/Storage/GXServices.cs @@ -15,7 +15,8 @@ namespace GeneXus.Services { public class GXServices { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Services.GXServices)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + public static string STORAGE_SERVICE = "Storage"; public static string STORAGE_APISERVICE = "StorageAPI"; public static string CACHE_SERVICE = "Cache"; @@ -178,8 +179,7 @@ public class GXService public class ServiceFactory { private static ExternalProvider externalProvider = null; - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Services.ServiceFactory)); - + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public static GXServices GetGXServices() { return GXServices.Instance; diff --git a/dotnet/src/dotnetframework/GxClasses/View/GXWebControls.cs b/dotnet/src/dotnetframework/GxClasses/View/GXWebControls.cs index 434bb2bf6..ff887b8a5 100644 --- a/dotnet/src/dotnetframework/GxClasses/View/GXWebControls.cs +++ b/dotnet/src/dotnetframework/GxClasses/View/GXWebControls.cs @@ -711,7 +711,7 @@ public void FromJSONObject(dynamic obj) public abstract class GXWebControl : IGxJSONAble, IGxJSONSerializable { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GXWebControl)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); bool ForeColorFlag; bool BackColorFlag; Color _ForeColor; diff --git a/dotnet/src/dotnetframework/GxDataInitialization/GXDataInitialization.cs b/dotnet/src/dotnetframework/GxDataInitialization/GXDataInitialization.cs index a6a5291ed..c90fb871e 100644 --- a/dotnet/src/dotnetframework/GxDataInitialization/GXDataInitialization.cs +++ b/dotnet/src/dotnetframework/GxDataInitialization/GXDataInitialization.cs @@ -26,7 +26,7 @@ public DynTrnInitializer() { } public class GXDataInitialization : GXProcedure { - static readonly ILog log = log4net.LogManager.GetLogger(typeof(GXDataInitialization)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public GXDataInitialization() { context = GxContext.CreateDefaultInstance(); diff --git a/dotnet/src/dotnetframework/GxExcel/GxExcelEPPlus.cs b/dotnet/src/dotnetframework/GxExcel/GxExcelEPPlus.cs index 134c531d2..2ebb4d027 100644 --- a/dotnet/src/dotnetframework/GxExcel/GxExcelEPPlus.cs +++ b/dotnet/src/dotnetframework/GxExcel/GxExcelEPPlus.cs @@ -10,9 +10,9 @@ namespace GeneXus.Office.ExcelGXEPPlus public class ExcelDocument : IGxError, IExcelDocument { - static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); - private ExcelPackage p; + private ExcelPackage p; public string dateFormat = "m/d/yy h:mm"; public bool OpenFromTemplate { get; set;} @@ -357,9 +357,9 @@ public short Init(string previousMsgError) public class ExcelCells : IExcelCells { - static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); - private IGxError m_errAccess; + private IGxError m_errAccess; private int pWidth, pHeight; private int pColPos; private ExcelWorksheet pSelectedSheet; diff --git a/dotnet/src/dotnetframework/GxExcel/GxExcelI.cs b/dotnet/src/dotnetframework/GxExcel/GxExcelI.cs index e5401195e..4fbe81549 100644 --- a/dotnet/src/dotnetframework/GxExcel/GxExcelI.cs +++ b/dotnet/src/dotnetframework/GxExcel/GxExcelI.cs @@ -12,9 +12,10 @@ namespace GeneXus.Office { public class ExcelDocumentI { - static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - public short Index = -1; + static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); + + public short Index = -1; private string fileName; [Obsolete("It is here for backward compatibility", false)] @@ -734,7 +735,7 @@ public short Underline public class IExcelDocumentWrapper : IExcelDocument { - static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); Interop.GXOFFICE2Lib.IExcelDocument doc; @@ -930,9 +931,8 @@ public void CalculateFormulas() #endif public class ExcelUtils { - static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - - public static void Show(string xlsFileName) + static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); + public static void Show(string xlsFileName) { Process p = new Process(); p.StartInfo.FileName = "excel"; diff --git a/dotnet/src/dotnetframework/GxExcel/GxExcelLite.cs b/dotnet/src/dotnetframework/GxExcel/GxExcelLite.cs index a17605cae..a7233b83d 100644 --- a/dotnet/src/dotnetframework/GxExcel/GxExcelLite.cs +++ b/dotnet/src/dotnetframework/GxExcel/GxExcelLite.cs @@ -11,7 +11,7 @@ namespace GeneXus.Office.ExcelLite { public class ExcelCells : IExcelCells { - static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); public ExcelCells(IGxError errAccess, object ef, int row, int col, int height, int width) { @@ -366,7 +366,7 @@ public int Color public class ExcelDocument : IGxError, IExcelDocument { - static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); public static string nmspace; public static string license; public static Assembly ass; diff --git a/dotnet/src/dotnetframework/GxMail/Exchange/ExchangeSession.cs b/dotnet/src/dotnetframework/GxMail/Exchange/ExchangeSession.cs index e74e2b95d..079858e07 100644 --- a/dotnet/src/dotnetframework/GxMail/Exchange/ExchangeSession.cs +++ b/dotnet/src/dotnetframework/GxMail/Exchange/ExchangeSession.cs @@ -10,7 +10,8 @@ namespace GeneXus.Mail.Exchange { public class ExchangeSession : IMailService { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(ExchangeSession)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + private string _attachDir = string.Empty; private string _userName = string.Empty; private string _password = string.Empty; @@ -139,7 +140,7 @@ public void Login(GXMailServiceSession sessionInfo) } catch (Exception e) { - log.Error("Exchange Login Error", e); + GXLogging.Error(log, "Exchange Login Error", e); HandleError(e, 3); } } diff --git a/dotnet/src/dotnetframework/GxMail/Exchange/Service.cs b/dotnet/src/dotnetframework/GxMail/Exchange/Service.cs index e1f617b16..a50ff52f4 100644 --- a/dotnet/src/dotnetframework/GxMail/Exchange/Service.cs +++ b/dotnet/src/dotnetframework/GxMail/Exchange/Service.cs @@ -8,9 +8,9 @@ namespace GeneXus.Mail.Exchange { public static class Service { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(Service)); - - static Service() + + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); + static Service() { CertificateCallback.Initialize(); } diff --git a/dotnet/src/dotnetframework/GxMail/Exchange/TraceListener.cs b/dotnet/src/dotnetframework/GxMail/Exchange/TraceListener.cs index 2b2106118..a8ed7829e 100644 --- a/dotnet/src/dotnetframework/GxMail/Exchange/TraceListener.cs +++ b/dotnet/src/dotnetframework/GxMail/Exchange/TraceListener.cs @@ -1,4 +1,4 @@ -using log4net; +using log4net; using Microsoft.Exchange.WebServices.Data; using System; using System.Collections.Generic; @@ -9,14 +9,10 @@ namespace GeneXus.Mail.Exchange { public class TraceListener : ITraceListener { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(TraceListener)); - - public void Trace(string traceType, string traceMessage) + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + public void Trace(string traceType, string traceMessage) { - if (log.IsDebugEnabled) - { - log.Debug(String.Format("Trace Type: {0} - Message: {1}", traceType, traceMessage)); - } + GXLogging.Debug(log, string.Format("Trace Type: {0} - Message: {1}", traceType, traceMessage)); } } } diff --git a/dotnet/src/dotnetframework/GxMail/GXMailSession.cs b/dotnet/src/dotnetframework/GxMail/GXMailSession.cs index 1f775cf3f..8d8d2bd73 100644 --- a/dotnet/src/dotnetframework/GxMail/GXMailSession.cs +++ b/dotnet/src/dotnetframework/GxMail/GXMailSession.cs @@ -6,7 +6,7 @@ namespace GeneXus.Mail public abstract class GXMailSession { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GXMailSession)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); protected short errorCode; protected string errorDescription; diff --git a/dotnet/src/dotnetframework/GxMail/GXPOP3Session.cs b/dotnet/src/dotnetframework/GxMail/GXPOP3Session.cs index 65ae678ed..2db01333e 100644 --- a/dotnet/src/dotnetframework/GxMail/GXPOP3Session.cs +++ b/dotnet/src/dotnetframework/GxMail/GXPOP3Session.cs @@ -8,7 +8,8 @@ namespace GeneXus.Mail public class GXPOP3Session : GXMailSession { - private static readonly ILog log = LogManager.GetLogger(typeof(GXSMTPSession)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + private IPOP3Session session; private short secure; private short newMessages; diff --git a/dotnet/src/dotnetframework/GxMail/GXSMTPSession.cs b/dotnet/src/dotnetframework/GxMail/GXSMTPSession.cs index efaff579a..4938afd0e 100644 --- a/dotnet/src/dotnetframework/GxMail/GXSMTPSession.cs +++ b/dotnet/src/dotnetframework/GxMail/GXSMTPSession.cs @@ -9,9 +9,8 @@ namespace GeneXus.Mail public class GXSMTPSession : GXMailSession { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GXSMTPSession)); - - private ISMTPSession session; + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + private ISMTPSession session; private string attachDir; private short authentication; private short secure; diff --git a/dotnet/src/dotnetframework/GxMail/MAPISession.cs b/dotnet/src/dotnetframework/GxMail/MAPISession.cs index 7e61fc0a0..62f201422 100644 --- a/dotnet/src/dotnetframework/GxMail/MAPISession.cs +++ b/dotnet/src/dotnetframework/GxMail/MAPISession.cs @@ -8,8 +8,7 @@ namespace GeneXus.Mail.Internals internal class MAPISession { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(MAPISession)); - + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private enum RecipientType { TO = 1, diff --git a/dotnet/src/dotnetframework/GxMail/MailMessage.cs b/dotnet/src/dotnetframework/GxMail/MailMessage.cs index 8ed31895f..e7afe0a91 100644 --- a/dotnet/src/dotnetframework/GxMail/MailMessage.cs +++ b/dotnet/src/dotnetframework/GxMail/MailMessage.cs @@ -14,7 +14,7 @@ namespace GeneXus.Mail.Internals.Pop3 internal class MailMessage { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(MailMessage)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private const string CRLF = "\r\n"; private static Hashtable monthList = new Hashtable(); diff --git a/dotnet/src/dotnetframework/GxMail/Mentalis/RFC822EndReader.cs b/dotnet/src/dotnetframework/GxMail/Mentalis/RFC822EndReader.cs index ebed69898..052f93e51 100644 --- a/dotnet/src/dotnetframework/GxMail/Mentalis/RFC822EndReader.cs +++ b/dotnet/src/dotnetframework/GxMail/Mentalis/RFC822EndReader.cs @@ -10,7 +10,7 @@ namespace GeneXus.Mail.Internals.Pop3 /// internal class RFC822EndReader : StreamReader { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(RFC822EndReader)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private const int BUFFER_SIZE = 1024; private bool textPlain = false; diff --git a/dotnet/src/dotnetframework/GxMail/OutlookSession.cs b/dotnet/src/dotnetframework/GxMail/OutlookSession.cs index 52ee82071..fc6d1aaf8 100644 --- a/dotnet/src/dotnetframework/GxMail/OutlookSession.cs +++ b/dotnet/src/dotnetframework/GxMail/OutlookSession.cs @@ -10,7 +10,7 @@ namespace GeneXus.Mail.Internals internal class OutlookSession { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(OutlookSession)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private enum RecipientType { diff --git a/dotnet/src/dotnetframework/GxMail/POP3Session.cs b/dotnet/src/dotnetframework/GxMail/POP3Session.cs index 75be7b0a3..f8e878428 100644 --- a/dotnet/src/dotnetframework/GxMail/POP3Session.cs +++ b/dotnet/src/dotnetframework/GxMail/POP3Session.cs @@ -15,8 +15,7 @@ namespace GeneXus.Mail.Internals internal class POP3Session : Pop3SessionBase { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(POP3Session)); - + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private const string CRLF = "\r\n"; private string userName; diff --git a/dotnet/src/dotnetframework/GxMail/POP3SessionOpenPop.cs b/dotnet/src/dotnetframework/GxMail/POP3SessionOpenPop.cs index 45cb1e583..3545ddfb7 100644 --- a/dotnet/src/dotnetframework/GxMail/POP3SessionOpenPop.cs +++ b/dotnet/src/dotnetframework/GxMail/POP3SessionOpenPop.cs @@ -13,9 +13,9 @@ namespace GeneXus.Mail { internal class POP3SessionOpenPop : Pop3SessionBase { - private static readonly ILog log = LogManager.GetLogger(typeof(POP3SessionOpenPop)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); - private Pop3Client client; + private Pop3Client client; public override int GetMessageCount() { diff --git a/dotnet/src/dotnetframework/GxMail/Pop3MailKit.cs b/dotnet/src/dotnetframework/GxMail/Pop3MailKit.cs index 0cb0ea71a..a7e9fd364 100644 --- a/dotnet/src/dotnetframework/GxMail/Pop3MailKit.cs +++ b/dotnet/src/dotnetframework/GxMail/Pop3MailKit.cs @@ -13,8 +13,7 @@ namespace GeneXus.Mail { internal class Pop3MailKit : Pop3SessionBase { - - private static readonly ILog log = LogManager.GetLogger(typeof(Pop3MailKit)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private Pop3Client client; diff --git a/dotnet/src/dotnetframework/GxMail/Pop3SessionBase.cs b/dotnet/src/dotnetframework/GxMail/Pop3SessionBase.cs index f59a38dc0..619d7d45e 100644 --- a/dotnet/src/dotnetframework/GxMail/Pop3SessionBase.cs +++ b/dotnet/src/dotnetframework/GxMail/Pop3SessionBase.cs @@ -13,7 +13,7 @@ internal abstract class Pop3SessionBase : IPOP3Session protected int lastReadMessage; protected int count; protected List uIds; - private static readonly ILog log = LogManager.GetLogger(typeof(Pop3SessionBase)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public bool DownloadAttachments { get; set; } @@ -63,11 +63,11 @@ public virtual string GetNextUID(GXPOP3Session session) public abstract void Receive(GXPOP3Session sessionInfo, GXMailMessage gxmessage); - protected void LogError(string title, string message, int code, Exception e, ILog log) + protected void LogError(string title, string message, int code, Exception e, IGXLogger log) { #if DEBUG - if (e != null && log.IsErrorEnabled) log.Error(message, e); + if (e != null && log.IsErrorEnabled) GXLogging.Error(log, message, e); #endif if (_sessionInfo != null) { @@ -75,20 +75,20 @@ protected void LogError(string title, string message, int code, Exception e, ILo } } - protected void LogError(string title, string message, int code, ILog log) + protected void LogError(string title, string message, int code, IGXLogger log) { LogError(title, message, code, null,log); } - protected void LogDebug(string title, string message, int code, ILog log) + protected void LogDebug(string title, string message, int code, IGXLogger log) { LogDebug(title, message, code, null, log); } - protected void LogDebug(string title, string message, int code, Exception e, ILog log) + protected void LogDebug(string title, string message, int code, Exception e, IGXLogger log) { #if DEBUG - if (e != null && log.IsDebugEnabled) log.Debug(message, e); + if (e != null && log.IsDebugEnabled) GXLogging.Debug(log, message, e); #endif if (_sessionInfo != null) { diff --git a/dotnet/src/dotnetframework/GxMail/SMTP/SmtpHelper.cs b/dotnet/src/dotnetframework/GxMail/SMTP/SmtpHelper.cs index 5d32bd771..23642d907 100644 --- a/dotnet/src/dotnetframework/GxMail/SMTP/SmtpHelper.cs +++ b/dotnet/src/dotnetframework/GxMail/SMTP/SmtpHelper.cs @@ -11,7 +11,7 @@ namespace GeneXus.Mail.Smtp public class SmtpHelper { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(SMTPMailClient)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); #if NETCORE const string SMTP_TRANSPORT = "_transport"; const string SMTP_CONNECTION = "_connection"; diff --git a/dotnet/src/dotnetframework/GxMail/SMTPMailClient.cs b/dotnet/src/dotnetframework/GxMail/SMTPMailClient.cs index f598c05a6..6a2acfa79 100644 --- a/dotnet/src/dotnetframework/GxMail/SMTPMailClient.cs +++ b/dotnet/src/dotnetframework/GxMail/SMTPMailClient.cs @@ -9,7 +9,7 @@ namespace GeneXus.Mail { internal class SMTPMailClient : ISMTPSession { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(SMTPMailClient)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); SmtpClient client; private string attachDir; diff --git a/dotnet/src/dotnetframework/GxMail/SMTPMailKit.cs b/dotnet/src/dotnetframework/GxMail/SMTPMailKit.cs index 24f11fdbc..d1b710e15 100644 --- a/dotnet/src/dotnetframework/GxMail/SMTPMailKit.cs +++ b/dotnet/src/dotnetframework/GxMail/SMTPMailKit.cs @@ -12,7 +12,7 @@ namespace GeneXus.Mail internal class SMTPMailKit : ISMTPSession { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(SMTPMailKit)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); SmtpClient client; private string attachDir; diff --git a/dotnet/src/dotnetframework/GxMail/SMTPSession.cs b/dotnet/src/dotnetframework/GxMail/SMTPSession.cs index f8f26847c..02de5d996 100644 --- a/dotnet/src/dotnetframework/GxMail/SMTPSession.cs +++ b/dotnet/src/dotnetframework/GxMail/SMTPSession.cs @@ -16,7 +16,7 @@ namespace GeneXus.Mail.Internals internal class SMTPSession: ISMTPSession { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(SMTPSession)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); #region Mail Constants private const int CR = 13; private const int LF = 10; diff --git a/dotnet/src/dotnetframework/GxOffice/ExcelSpreadsheetGXWrapper.cs b/dotnet/src/dotnetframework/GxOffice/ExcelSpreadsheetGXWrapper.cs index a1ac17645..cc839e38c 100644 --- a/dotnet/src/dotnetframework/GxOffice/ExcelSpreadsheetGXWrapper.cs +++ b/dotnet/src/dotnetframework/GxOffice/ExcelSpreadsheetGXWrapper.cs @@ -7,7 +7,7 @@ namespace GeneXus.MSOffice.Excel { public class ExcelSpreadsheetGXWrapper : IGXError { - private static readonly ILog logger = LogManager.GetLogger(typeof(ExcelSpreadsheetGXWrapper)); + private static readonly IGXLogger logger = GXLoggerFactory.GetLogger(); private int _errCode; private string _errDescription = string.Empty; private IExcelWorksheet _currentWorksheet; @@ -58,7 +58,7 @@ public bool Open(string filePath, string template) { try { - logger.Debug("Opening Excel file: " + filePath); + GXLogging.Debug(logger, "Opening Excel file: " + filePath); _document = ExcelFactory.Create(this, filePath, template); if (_autofit) { @@ -75,7 +75,7 @@ public bool Open(string filePath, string template) } catch (Exception e)//InvalidOpertaionException { - logger.Error("Excel File could not be loaded", e); + GXLogging.Error(logger, "Excel File could not be loaded", e); SetError(ErrorCodes.FILE_EXCEPTION, "Could not open file"); } return _document != null; @@ -150,13 +150,13 @@ public ExcelCells GetCell(int rowIdx, int colIdx) public void SetError(ExcelException e) { SetError(e.ErrorCode, e.ErrorDescription); - logger.Error(e.ErrorDescription, e); + GXLogging.Error(logger, e.ErrorDescription, e); } public void SetError(string errorMsg, ExcelException e) { SetError(e.ErrorCode, e.ErrorDescription); - logger.Error(errorMsg); + GXLogging.Error(logger, errorMsg); } public ExcelCells GetCells(int rowIdx, int colIdx, int rowCount, int colCount) diff --git a/dotnet/src/dotnetframework/GxOffice/poi/xssf/ExcelCells.cs b/dotnet/src/dotnetframework/GxOffice/poi/xssf/ExcelCells.cs index b7b95ef1a..135a5d14d 100644 --- a/dotnet/src/dotnetframework/GxOffice/poi/xssf/ExcelCells.cs +++ b/dotnet/src/dotnetframework/GxOffice/poi/xssf/ExcelCells.cs @@ -14,7 +14,8 @@ namespace GeneXus.MSOffice.Excel.Poi.Xssf { public class ExcelCells : IExcelCellRange { - private static readonly ILog logger = LogManager.GetLogger(typeof(ExcelCells)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + protected IGXError _errorHandler; protected ExcelSpreadsheet doc; protected int cellCount; @@ -428,7 +429,7 @@ public void SetSize(double value) } catch (Exception ex) { - GXLogging.Error(logger, "SetSize error", ex); + GXLogging.Error(log, "SetSize error", ex); } } diff --git a/dotnet/src/dotnetframework/GxOffice/poi/xssf/ExcelSpreadsheet.cs b/dotnet/src/dotnetframework/GxOffice/poi/xssf/ExcelSpreadsheet.cs index c74e4046e..8200cede2 100644 --- a/dotnet/src/dotnetframework/GxOffice/poi/xssf/ExcelSpreadsheet.cs +++ b/dotnet/src/dotnetframework/GxOffice/poi/xssf/ExcelSpreadsheet.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using GeneXus.Application; -using log4net; using NPOI.SS.UserModel; using NPOI.Util; using NPOI.XSSF.UserModel; @@ -11,7 +10,9 @@ namespace GeneXus.MSOffice.Excel.Poi.Xssf { public class ExcelSpreadsheet : IExcelSpreadsheet { - private static readonly ILog logger = LogManager.GetLogger(typeof(ExcelSpreadsheet)); + + static readonly IGXLogger logger = GXLoggerFactory.GetLogger(); + private XSSFWorkbook _workbook; private string _documentFileName; private bool _autoFitColumnsOnSave = false; @@ -247,7 +248,7 @@ private void RecalculateFormulas() } catch (Exception e) { - logger.Error("recalculateFormulas", e); + GXLogging.Error(logger, "recalculateFormulas", e); } } diff --git a/dotnet/src/dotnetframework/GxPdfReportsCS/PDFReportItext.cs b/dotnet/src/dotnetframework/GxPdfReportsCS/PDFReportItext.cs index 61b8d0b30..d47cae1c7 100644 --- a/dotnet/src/dotnetframework/GxPdfReportsCS/PDFReportItext.cs +++ b/dotnet/src/dotnetframework/GxPdfReportsCS/PDFReportItext.cs @@ -37,9 +37,7 @@ internal enum VerticalAlign public class PDFReportItextSharp : IReportHandler { private int lineHeight, pageLines; - - static ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - + static IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); private iTextSharp.text.Rectangle pageSize; private BaseFont baseFont; Barcode barcode = null; @@ -2362,7 +2360,7 @@ internal bool SetComplainceLevel(PdfConformanceLevel level) public class ParseINI { - static ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + static IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); private static int MAX_LINE_LENGTH=255; private static String GENERAL="&General&"; @@ -2889,9 +2887,7 @@ public class Const public class NativeSharpFunctionsMS { - - static ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - + static IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); public int shellExecute(String cmd, String fileName) { Process p = new Process(); @@ -3166,7 +3162,7 @@ public class Type1FontMetrics public class MSPDFFontDescriptor { - static ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + static IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); private static String TRUE_TYPE_REGISTRY_SIGNATURE = "(TrueType)"; private static String REGISTRY_FONTS_ENTRY = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Fonts"; // Fonts NT/2000 diff --git a/dotnet/src/dotnetframework/GxPdfReportsCS/PdfReportInterface.cs b/dotnet/src/dotnetframework/GxPdfReportsCS/PdfReportInterface.cs index 83c226784..de9010170 100644 --- a/dotnet/src/dotnetframework/GxPdfReportsCS/PdfReportInterface.cs +++ b/dotnet/src/dotnetframework/GxPdfReportsCS/PdfReportInterface.cs @@ -7,8 +7,7 @@ namespace GeneXus.Printer public class GxReportBuilderPdf : IReportHandler { - static ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - + static IGXLogger log = GXLoggerFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); string _appPath; IReportHandler _pdfReport; diff --git a/dotnet/src/dotnetframework/GxSearch/DocumentHandler.cs b/dotnet/src/dotnetframework/GxSearch/DocumentHandler.cs index 00914d6c9..4935ca55e 100644 --- a/dotnet/src/dotnetframework/GxSearch/DocumentHandler.cs +++ b/dotnet/src/dotnetframework/GxSearch/DocumentHandler.cs @@ -25,7 +25,7 @@ namespace GeneXus.Utils { public class DocumentHandler { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Utils.DocumentHandler)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); static IndexReader reader; static ConcurrentDictionary queries = new ConcurrentDictionary(); @@ -152,10 +152,10 @@ public interface IDocumentHandler public class NTidyHTMLHandler : IDocumentHandler { #if !NETCORE - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Utils.DocumentHandler)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); Assembly ntidy; #endif - public NTidyHTMLHandler() + public NTidyHTMLHandler() { #if !NETCORE try diff --git a/dotnet/src/dotnetframework/GxSearch/Indexer.cs b/dotnet/src/dotnetframework/GxSearch/Indexer.cs index 8ca23e70f..7373c3b19 100644 --- a/dotnet/src/dotnetframework/GxSearch/Indexer.cs +++ b/dotnet/src/dotnetframework/GxSearch/Indexer.cs @@ -24,7 +24,7 @@ namespace GeneXus.Search [SecuritySafeCritical] public sealed class Indexer { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Search.Indexer)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public static Lucene.Net.Util.Version LUCENE_VERSION = Lucene.Net.Util.Version.LUCENE_24; #region Singleton diff --git a/dotnet/src/dotnetframework/GxSearch/Searcher.cs b/dotnet/src/dotnetframework/GxSearch/Searcher.cs index 40d9a1cda..8d913d78a 100644 --- a/dotnet/src/dotnetframework/GxSearch/Searcher.cs +++ b/dotnet/src/dotnetframework/GxSearch/Searcher.cs @@ -18,7 +18,7 @@ namespace GeneXus.Search [SecuritySafeCritical] public sealed class Searcher { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Search.Searcher)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); #region Singleton private static Searcher m_instance = new Searcher(); diff --git a/dotnet/src/dotnetframework/GxSearch/Settings.cs b/dotnet/src/dotnetframework/GxSearch/Settings.cs index 1bef3ee9e..1c7d68e0e 100644 --- a/dotnet/src/dotnetframework/GxSearch/Settings.cs +++ b/dotnet/src/dotnetframework/GxSearch/Settings.cs @@ -11,7 +11,7 @@ namespace GeneXus.Search [SecuritySafeCritical] public class Settings { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Search.Settings)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private static Settings m_instance = new Settings(); private Lucene.Net.Store.Directory m_storeFolder; private string m_indexFolder; diff --git a/dotnet/src/dotnetframework/GxSearch/SpellChecker.cs b/dotnet/src/dotnetframework/GxSearch/SpellChecker.cs index a132a03d7..a3c442a52 100644 --- a/dotnet/src/dotnetframework/GxSearch/SpellChecker.cs +++ b/dotnet/src/dotnetframework/GxSearch/SpellChecker.cs @@ -12,7 +12,7 @@ namespace GeneXus.Search { public sealed class Spelling { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Search.Indexer)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); #region Singleton private static Spelling m_instance = new Spelling(); diff --git a/dotnet/src/dotnetframework/GxWebSocket/WSHandler.cs b/dotnet/src/dotnetframework/GxWebSocket/WSHandler.cs index b4f51285f..bb81262c5 100644 --- a/dotnet/src/dotnetframework/GxWebSocket/WSHandler.cs +++ b/dotnet/src/dotnetframework/GxWebSocket/WSHandler.cs @@ -16,7 +16,7 @@ namespace GeneXus.Http.WebSocket { public class WSHandler : WebSocketHandler, IGXWebSocketAsync { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(WSHandler)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); private const string GX_NOTIFICATIONINFO_NAME = "GeneXus.Core.genexus.server.SdtNotificationInfo"; @@ -127,7 +127,7 @@ public override void OnError() string key = GetClientKey(this); if (!ExecuteHandler(HandlerType.OnError, new Object[] { key })) { - log.Debug($"An unknown error ocurred on WebSocket client ('{key}')"); + GXLogging.Debug(log, $"An unknown error ocurred on WebSocket client ('{key}')"); } OnSessionClosed?.Invoke(key, "WebSocket Error"); } @@ -146,7 +146,7 @@ private static void LogDebug(string msg) private static void LogError(string msg, Exception e = null) { - GXLogging.Error(log, e, msg); + GXLogging.Error(log, msg, e); } public enum HandlerType { diff --git a/dotnet/src/dotnetframework/Projects/StoreManager/Store/StoreManager.cs b/dotnet/src/dotnetframework/Projects/StoreManager/Store/StoreManager.cs index 3d95f7675..87f7a08d9 100644 --- a/dotnet/src/dotnetframework/Projects/StoreManager/Store/StoreManager.cs +++ b/dotnet/src/dotnetframework/Projects/StoreManager/Store/StoreManager.cs @@ -13,8 +13,7 @@ namespace GeneXus.SD.Store { public class StoreManager { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(StoreManager)); - + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); public int ErrCode { get; set; diff --git a/dotnet/src/dotnetframework/Providers/Cache/GxMemcached/GxMemcached.cs b/dotnet/src/dotnetframework/Providers/Cache/GxMemcached/GxMemcached.cs index 2a5945e01..917758d7e 100644 --- a/dotnet/src/dotnetframework/Providers/Cache/GxMemcached/GxMemcached.cs +++ b/dotnet/src/dotnetframework/Providers/Cache/GxMemcached/GxMemcached.cs @@ -15,7 +15,7 @@ namespace GeneXus.Cache [SecuritySafeCritical] public class Memcached : ICacheService2 { - private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(Memcached)); + static readonly IGXLogger log = GXLoggerFactory.GetLogger(); MemcachedClient _cache; const int DEFAULT_MEMCACHED_PORT = 11211; diff --git a/dotnet/src/dotnetframework/Providers/Cache/GxRedis/GxRedis.cs b/dotnet/src/dotnetframework/Providers/Cache/GxRedis/GxRedis.cs index 80d5d9781..f15c789e9 100644 --- a/dotnet/src/dotnetframework/Providers/Cache/GxRedis/GxRedis.cs +++ b/dotnet/src/dotnetframework/Providers/Cache/GxRedis/GxRedis.cs @@ -17,7 +17,8 @@ namespace GeneXus.Cache { public sealed class Redis : ICacheService2 { - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(Redis)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); + ConnectionMultiplexer _redisConnection; IDatabase _redisDatabase; ConfigurationOptions _redisConnectionOptions; diff --git a/dotnet/src/extensions/Azure/Handlers/HttpHandler/GXHttpAzureContextAccessor.cs b/dotnet/src/extensions/Azure/Handlers/HttpHandler/GXHttpAzureContextAccessor.cs index bc58ac9d3..2a9e3c97a 100644 --- a/dotnet/src/extensions/Azure/Handlers/HttpHandler/GXHttpAzureContextAccessor.cs +++ b/dotnet/src/extensions/Azure/Handlers/HttpHandler/GXHttpAzureContextAccessor.cs @@ -26,7 +26,7 @@ public class GXHttpAzureContextAccessor : HttpContext public HttpResponse httpResponseData; private ICacheService2 _redis; private string sessionId; - private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GXHttpAzureContextAccessor)); + private static readonly IGXLogger log = GXLoggerFactory.GetLogger(); internal const string AzureSessionId = "GX_AZURE_SESSIONID"; public GXHttpAzureContextAccessor(HttpRequestData requestData, HttpResponseData responseData, ICacheService2 redis) {