diff --git a/src/Umbraco.Infrastructure/Logging/Viewer/LogViewerComposer.cs b/src/Umbraco.Infrastructure/Logging/Viewer/LogViewerComposer.cs index ee115be325..8244fa696d 100644 --- a/src/Umbraco.Infrastructure/Logging/Viewer/LogViewerComposer.cs +++ b/src/Umbraco.Infrastructure/Logging/Viewer/LogViewerComposer.cs @@ -1,5 +1,7 @@ -using Umbraco.Core.Composing; -using Umbraco.Core.IO; +using System.IO; +using Serilog; +using Umbraco.Core.Composing; +using Umbraco.Core.Hosting; namespace Umbraco.Core.Logging.Viewer { @@ -9,8 +11,26 @@ namespace Umbraco.Core.Logging.Viewer { public void Compose(Composition composition) { + + + composition.RegisterUnique(factory => + { + var hostingEnvironment = factory.GetInstance(); + return new LoggingConfiguration( + Path.Combine(hostingEnvironment.ApplicationPhysicalPath, "App_Data\\Logs"), + Path.Combine(hostingEnvironment.ApplicationPhysicalPath, "config\\serilog.config"), + Path.Combine(hostingEnvironment.ApplicationPhysicalPath, "config\\serilog.user.config")); + }); composition.RegisterUnique(); composition.SetLogViewer(); + composition.RegisterUnique(factory => + { + + return new SerilogJsonLogViewer(factory.GetInstance(), + factory.GetInstance(), + factory.GetInstance(), + Log.Logger); + } ); } } } diff --git a/src/Umbraco.Infrastructure/Logging/Viewer/SerilogLogViewerSourceBase.cs b/src/Umbraco.Infrastructure/Logging/Viewer/SerilogLogViewerSourceBase.cs index 7c8503a37e..278f3d8d00 100644 --- a/src/Umbraco.Infrastructure/Logging/Viewer/SerilogLogViewerSourceBase.cs +++ b/src/Umbraco.Infrastructure/Logging/Viewer/SerilogLogViewerSourceBase.cs @@ -14,7 +14,7 @@ namespace Umbraco.Core.Logging.Viewer private readonly global::Serilog.ILogger _serilogLog; protected SerilogLogViewerSourceBase(ILogViewerConfig logViewerConfig, global::Serilog.ILogger serilogLog) - { + { _logViewerConfig = logViewerConfig; _serilogLog = serilogLog; } @@ -50,7 +50,7 @@ namespace Umbraco.Core.Logging.Viewer /// public string GetLogLevel() { - var logLevel = Enum.GetValues(typeof(LogEventLevel)).Cast().Where(_serilogLog.IsEnabled)?.Min() ?? null; + var logLevel = Enum.GetValues(typeof(LogEventLevel)).Cast().Where(_serilogLog.IsEnabled).DefaultIfEmpty(LogEventLevel.Information)?.Min() ?? null; return logLevel?.ToString() ?? ""; } @@ -131,6 +131,6 @@ namespace Umbraco.Core.Logging.Viewer }; } - + } } diff --git a/src/Umbraco.Infrastructure/Scheduling/ScheduledPublishing.cs b/src/Umbraco.Infrastructure/Scheduling/ScheduledPublishing.cs index fea16999fd..6eb117b677 100644 --- a/src/Umbraco.Infrastructure/Scheduling/ScheduledPublishing.cs +++ b/src/Umbraco.Infrastructure/Scheduling/ScheduledPublishing.cs @@ -70,7 +70,8 @@ namespace Umbraco.Web.Scheduling // but then what should be its "scope"? could we attach it to scopes? // - and we should definitively *not* have to flush it here (should be auto) // - using (var contextReference = _umbracoContextFactory.EnsureUmbracoContext()) + using ( + var contextReference = _umbracoContextFactory.EnsureUmbracoContext()) { try { diff --git a/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs b/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs index 3facf1b77f..0fe784f421 100644 --- a/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs +++ b/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs @@ -84,7 +84,6 @@ namespace Umbraco.Web.Common.Extensions IHttpContextAccessor httpContextAccessor = new HttpContextAccessor(); services.AddSingleton(httpContextAccessor); - var requestCache = new GenericDictionaryRequestAppCache(() => httpContextAccessor.HttpContext.Items); services.AddUmbracoCore(webHostEnvironment, diff --git a/src/Umbraco.Web/UmbracoApplicationBase.cs b/src/Umbraco.Web/UmbracoApplicationBase.cs index 1f90bc7d13..799b627f2c 100644 --- a/src/Umbraco.Web/UmbracoApplicationBase.cs +++ b/src/Umbraco.Web/UmbracoApplicationBase.cs @@ -73,7 +73,7 @@ namespace Umbraco.Web } protected UmbracoApplicationBase(ILogger logger, Configs configs, IIOHelper ioHelper, IProfiler profiler, IHostingEnvironment hostingEnvironment, IBackOfficeInfo backOfficeInfo) - { + { if (!Umbraco.Composing.Current.IsInitialized) { Logger = logger;