diff --git a/dotnet/src/dotnetcore/GxClasses/GxClasses.csproj b/dotnet/src/dotnetcore/GxClasses/GxClasses.csproj index bb08809b2..214b32620 100644 --- a/dotnet/src/dotnetcore/GxClasses/GxClasses.csproj +++ b/dotnet/src/dotnetcore/GxClasses/GxClasses.csproj @@ -160,6 +160,7 @@ + diff --git a/dotnet/src/dotnetcore/GxClasses/Services/LogService/AzureAppInsights/AzureAppInsightsLogProvider.cs b/dotnet/src/dotnetcore/GxClasses/Services/LogService/AzureAppInsights/AzureAppInsightsLogProvider.cs index a989b4843..098aec546 100644 --- a/dotnet/src/dotnetcore/GxClasses/Services/LogService/AzureAppInsights/AzureAppInsightsLogProvider.cs +++ b/dotnet/src/dotnetcore/GxClasses/Services/LogService/AzureAppInsights/AzureAppInsightsLogProvider.cs @@ -1,6 +1,5 @@ using System; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Configuration; namespace GeneXus.Services.Log { @@ -17,7 +16,6 @@ public static ILoggerFactory GetLoggerFactory() loggerFactory = LoggerFactory.Create(builder => builder.AddApplicationInsights( configureTelemetryConfiguration: (config) => - //config.SetAzureTokenCredential config.ConnectionString = appInsightsConnection, configureApplicationInsightsLoggerOptions: (options) => { } ) diff --git a/dotnet/src/dotnetcore/GxNetCoreStartup/Startup.cs b/dotnet/src/dotnetcore/GxNetCoreStartup/Startup.cs index c05a525dd..95acd9dc8 100644 --- a/dotnet/src/dotnetcore/GxNetCoreStartup/Startup.cs +++ b/dotnet/src/dotnetcore/GxNetCoreStartup/Startup.cs @@ -14,7 +14,6 @@ using GeneXus.Services.OpenTelemetry; using GeneXus.Utils; using GxClasses.Web.Middleware; -using log4net; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Antiforgery; using Microsoft.AspNetCore.Builder; @@ -36,7 +35,6 @@ using OpenTelemetry.Resources; using StackExchange.Redis; - namespace GeneXus.Application { public class Program @@ -171,6 +169,7 @@ public class 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(); @@ -193,7 +192,6 @@ public class Startup public List servicesBase = new List(); private GXRouting gxRouting; - static bool InitializeHttpContext() { GxContext.IsHttpContext = true; @@ -348,11 +346,8 @@ 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}"; - Config.GetValueOf("LOG_OUTPUT", out string logProvider); - if (logProvider == "ASPNetTraceAppender" || logProvider == "ConsoleAppender" || logProvider == "EventLogAppender" || logProvider == "RollingFile") - { - LogConfiguration.SetupLog4Net(); - } + LogConfiguration.SetupLog4Net(); + var provider = new FileExtensionContentTypeProvider(); //mappings provider.Mappings[".json"] = "application/json"; diff --git a/dotnet/src/dotnetframework/GxClasses/Configuration/LogConfiguration.cs b/dotnet/src/dotnetframework/GxClasses/Configuration/LogConfiguration.cs index 56b013d94..6a047d681 100644 --- a/dotnet/src/dotnetframework/GxClasses/Configuration/LogConfiguration.cs +++ b/dotnet/src/dotnetframework/GxClasses/Configuration/LogConfiguration.cs @@ -20,7 +20,11 @@ internal class LogConfiguration public static void SetupLog4Net() { - SetupLog4NetFromEnvironmentVariables(); + Config.GetValueOf("LOG_OUTPUT", out string logProvider); + if (logProvider == "ASPNetTraceAppender" || logProvider == "ConsoleAppender" || logProvider == "EventLogAppender" || logProvider == "RollingFile") + { + SetupLog4NetFromEnvironmentVariables(); + } } private static void SetupLog4NetFromEnvironmentVariables() diff --git a/dotnet/src/dotnetframework/GxClasses/Core/GXApplication.cs b/dotnet/src/dotnetframework/GxClasses/Core/GXApplication.cs index e33feecae..8aa6e227b 100644 --- a/dotnet/src/dotnetframework/GxClasses/Core/GXApplication.cs +++ b/dotnet/src/dotnetframework/GxClasses/Core/GXApplication.cs @@ -322,7 +322,7 @@ internal class GxApplication public class GxContext : IGxContext { private static IGXLogger log = null; - public static bool configurationLoaded = Config.configLoaded; + internal 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"; @@ -460,7 +460,7 @@ static IGXLogger Logger { get { - if (configurationLoaded) + if (Config.configLoaded) { if (log == null) { @@ -1016,7 +1016,6 @@ private bool CheckFileExists(string fileName) public void StatusMessage(string message) { StackFrame frame = new StackFrame(1); - IGXLogger statusLog = GXLoggerFactory.GetLogger(frame.GetMethod().DeclaringType.FullName); GXLogging.Info(statusLog, message); Console.WriteLine(message); diff --git a/dotnet/src/dotnetframework/GxClasses/Core/gxconfig.cs b/dotnet/src/dotnetframework/GxClasses/Core/gxconfig.cs index 3deb9ba8f..6d946cbaf 100644 --- a/dotnet/src/dotnetframework/GxClasses/Core/gxconfig.cs +++ b/dotnet/src/dotnetframework/GxClasses/Core/gxconfig.cs @@ -43,7 +43,7 @@ public class Config private static string configFileName; public static string loadedConfigFile; private static bool configLog = true; - public static bool configLoaded; + internal static bool configLoaded; static NameValueCollection _config; static ConcurrentDictionary s_confMapping; const string CONFMAPPING_FILE = "confmapping.json"; @@ -81,11 +81,7 @@ public static void ParseArgs(ref string[] args) } } - Config.GetValueOf("LOG_OUTPUT", out string logProvider); - if (logProvider == "ASPNetTraceAppender" || logProvider == "ConsoleAppender" || logProvider == "EventLogAppender" || logProvider == "RollingFile") - { - LogConfiguration.SetupLog4Net(); - } + LogConfiguration.SetupLog4Net(); } private static void RemoveArg(ref string[] args, ref int i) @@ -434,7 +430,7 @@ public static CultureInfo GetCultureForLang(string lang) } #if NETCORE - public static IConfiguration ConfigRoot { get; set; } + public static IConfiguration ConfigRoot { get ; set; } const string Log4NetShortName = "log4net"; static Version Log4NetVersion = new Version(2, 0, 15); @@ -444,17 +440,13 @@ public static CultureInfo GetCultureForLang(string lang) const string ITextSharpFileName = "iTextSharp.dll"; const string ITextSharpAssemblyName = "itextsharp"; private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) - { - 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); - } + { + var requestedAssembly = new AssemblyName(args.Name); + if (requestedAssembly.Name == Log4NetShortName){ + requestedAssembly.Version = Log4NetVersion; + return Assembly.Load(requestedAssembly); } - + if (args.Name.StartsWith(ConfigurationManagerBak)) { string fileName = Path.Combine(FileUtil.GetStartupDirectory(), ConfigurationManagerFileName); @@ -621,7 +613,6 @@ static NameValueCollection config } configLoaded = true; - GxContext.configurationLoaded = configLoaded; log = GXLoggerFactory.GetLogger(); string logConfigFile = GxContext.IsHttpContext ? "log.config" : "log.console.config"; diff --git a/dotnet/src/dotnetframework/GxClasses/Data/GXDataCommon.cs b/dotnet/src/dotnetframework/GxClasses/Data/GXDataCommon.cs index e94103aea..a329f751f 100644 --- a/dotnet/src/dotnetframework/GxClasses/Data/GXDataCommon.cs +++ b/dotnet/src/dotnetframework/GxClasses/Data/GXDataCommon.cs @@ -2647,7 +2647,6 @@ 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(); diff --git a/dotnet/test/DotNetCoreWebUnitTest/Middleware/MiddlewareTest.cs b/dotnet/test/DotNetCoreWebUnitTest/Middleware/MiddlewareTest.cs index 7a22fdddc..2631297ca 100644 --- a/dotnet/test/DotNetCoreWebUnitTest/Middleware/MiddlewareTest.cs +++ b/dotnet/test/DotNetCoreWebUnitTest/Middleware/MiddlewareTest.cs @@ -16,9 +16,9 @@ public class MiddlewareTest protected TestServer server; public MiddlewareTest() - { - GXRouting.ContentRootPath = Directory.GetCurrentDirectory(); + { server = new TestServer(WebHost.CreateDefaultBuilder().UseStartup().UseEnvironment(DOTNET_ENVIRONMENT)); + GXRouting.ContentRootPath = Directory.GetCurrentDirectory(); server.PreserveExecutionContext= true; server.CreateClient(); }