From e886086aed67f75623f7b8d6fa9e990cd9ee4529 Mon Sep 17 00:00:00 2001 From: Warren Date: Tue, 31 Jul 2018 10:21:26 +0100 Subject: [PATCH] Adds in a new File sink - that will generate a JSON log file in the CLEF format so that it can be imported into a local copy of SEQ to help with filtering/finding log items --- src/Umbraco.Core/Logging/Logger.cs | 13 ++++++++++++- src/Umbraco.Core/Umbraco.Core.csproj | 3 +++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Core/Logging/Logger.cs b/src/Umbraco.Core/Logging/Logger.cs index 94059d4df3..84ebf7f529 100644 --- a/src/Umbraco.Core/Logging/Logger.cs +++ b/src/Umbraco.Core/Logging/Logger.cs @@ -7,6 +7,7 @@ using Umbraco.Core.Configuration; using Umbraco.Core.Diagnostics; using Serilog; using Serilog.Events; +using Serilog.Formatting.Compact; namespace Umbraco.Core.Logging { @@ -37,11 +38,21 @@ namespace Umbraco.Core.Logging .Enrich.WithThreadId() .Enrich.WithProperty("AppDomainId", AppDomain.CurrentDomain.Id) .Enrich.WithProperty("AppDomainAppId", HttpRuntime.AppDomainAppId.ReplaceNonAlphanumericChars(string.Empty)) - .WriteTo.File(AppDomain.CurrentDomain.BaseDirectory + @"\App_Data\Logs\UmbracoTraceLog.txt", //Our main app Logfile + + //Main .txt logfile - in similar format to older Log4Net output + .WriteTo.File(AppDomain.CurrentDomain.BaseDirectory + @"\App_Data\Logs\UmbracoTraceLog.txt", rollingInterval: RollingInterval.Day, restrictedToMinimumLevel: LogEventLevel.Debug, retainedFileCountLimit: null, //Setting to null means we keep all files - default is 31 days outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss,fff} [P{ProcessId}/D{AppDomainId}/T{ThreadId}] {Level:u4} {Message:lj}{NewLine}{Exception}") + + //.clef format (Compact log event format, that can be imported into local SEQ & will make searching/filtering logs easier) + .WriteTo.File(new CompactJsonFormatter(), AppDomain.CurrentDomain.BaseDirectory + @"\App_Data\Logs\UmbracoTraceLog.json", + rollingInterval: RollingInterval.Day, //Create a new JSON file every day + retainedFileCountLimit: null, //Setting to null means we keep all files - default is 31 days + restrictedToMinimumLevel: LogEventLevel.Debug) + + //Read any custom user configuration of logging from serilog config file .ReadFrom.AppSettings(filePath: AppDomain.CurrentDomain.BaseDirectory + @"\config\serilog.config") .CreateLogger(); diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 898882c97e..fddf62bdb6 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -83,6 +83,9 @@ 3.0.0 + + 1.0.0 + 2.1.2