Fix for logviewer issue

This commit is contained in:
Bjarke Berg
2020-04-24 11:52:12 +02:00
parent 56b94b53b1
commit 3e50333a3b
5 changed files with 28 additions and 8 deletions

View File

@@ -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<ILoggingConfiguration>(factory =>
{
var hostingEnvironment = factory.GetInstance<IHostingEnvironment>();
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<ILogViewerConfig, LogViewerConfig>();
composition.SetLogViewer<SerilogJsonLogViewer>();
composition.RegisterUnique<ILogViewer>(factory =>
{
return new SerilogJsonLogViewer(factory.GetInstance<ILogger>(),
factory.GetInstance<ILogViewerConfig>(),
factory.GetInstance<ILoggingConfiguration>(),
Log.Logger);
} );
}
}
}

View File

@@ -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
/// <returns></returns>
public string GetLogLevel()
{
var logLevel = Enum.GetValues(typeof(LogEventLevel)).Cast<LogEventLevel>().Where(_serilogLog.IsEnabled)?.Min() ?? null;
var logLevel = Enum.GetValues(typeof(LogEventLevel)).Cast<LogEventLevel>().Where(_serilogLog.IsEnabled).DefaultIfEmpty(LogEventLevel.Information)?.Min() ?? null;
return logLevel?.ToString() ?? "";
}
@@ -131,6 +131,6 @@ namespace Umbraco.Core.Logging.Viewer
};
}
}
}

View File

@@ -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
{

View File

@@ -84,7 +84,6 @@ namespace Umbraco.Web.Common.Extensions
IHttpContextAccessor httpContextAccessor = new HttpContextAccessor();
services.AddSingleton<IHttpContextAccessor>(httpContextAccessor);
var requestCache = new GenericDictionaryRequestAppCache(() => httpContextAccessor.HttpContext.Items);
services.AddUmbracoCore(webHostEnvironment,

View File

@@ -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;