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
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
@@ -83,6 +83,9 @@
|
||||
<PackageReference Include="Serilog.Enrichers.Thread">
|
||||
<Version>3.0.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Serilog.Formatting.Compact">
|
||||
<Version>1.0.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Serilog.Settings.AppSettings">
|
||||
<Version>2.1.2</Version>
|
||||
</PackageReference>
|
||||
|
||||
Reference in New Issue
Block a user