#5373 - Removed configuration options that we don't want to support. The other options can be archived using the original file sink.
This commit is contained in:
@@ -3,10 +3,7 @@
|
||||
<appSettings>
|
||||
|
||||
<add key="serilog:using:File" value="Umbraco.Core" xdt:Transform="SetAttributes(value)" xdt:Locator="Match(key)"/>
|
||||
<add key="serilog:write-to:File.shared" value="false" xdt:Transform="SetAttributes(value)" xdt:Locator="Match(key)"/>
|
||||
<add key="serilog:write-to:File.buffered" value="true" xdt:Transform="InsertIfMissing" xdt:Locator="Match(key)"/>
|
||||
<add key="serilog:write-to:File.async" value="true" xdt:Transform="InsertIfMissing" xdt:Locator="Match(key)"/>
|
||||
<add key="serilog:write-to:File.asyncKeepFileOpen" value="false" xdt:Transform="InsertIfMissing" xdt:Locator="Match(key)"/>
|
||||
<add key="serilog:write-to:File.shared" xdt:Transform="Remove" xdt:Locator="Match(key)"/>
|
||||
|
||||
</appSettings>
|
||||
</configuration>
|
||||
|
||||
@@ -70,8 +70,6 @@ namespace Umbraco.Core.Logging.Serilog
|
||||
/// </remarks>
|
||||
public static LoggerConfiguration File(this LoggerSinkConfiguration configuration, ITextFormatter formatter,
|
||||
string path,
|
||||
bool shared = false,
|
||||
bool buffered = false,
|
||||
LogEventLevel restrictedToMinimumLevel = LogEventLevel.Verbose,
|
||||
LoggingLevelSwitch levelSwitch = null,
|
||||
long? fileSizeLimitBytes = 1073741824,
|
||||
@@ -79,56 +77,26 @@ namespace Umbraco.Core.Logging.Serilog
|
||||
RollingInterval rollingInterval = RollingInterval.Infinite,
|
||||
bool rollOnFileSizeLimit = false,
|
||||
int? retainedFileCountLimit = 31,
|
||||
Encoding encoding = null,
|
||||
bool async = false,
|
||||
bool asyncBlockWhenFull = false,
|
||||
int asyncBufferSize = 10000,
|
||||
bool asyncKeepFileOpen = true)
|
||||
Encoding encoding = null
|
||||
)
|
||||
{
|
||||
LoggerConfiguration GetFileSink(LoggerSinkConfiguration c)
|
||||
{
|
||||
return c.File(
|
||||
formatter,
|
||||
path,
|
||||
restrictedToMinimumLevel,
|
||||
fileSizeLimitBytes,
|
||||
levelSwitch,
|
||||
buffered,
|
||||
shared,
|
||||
flushToDiskInterval,
|
||||
rollingInterval,
|
||||
rollOnFileSizeLimit,
|
||||
retainedFileCountLimit,
|
||||
encoding);
|
||||
}
|
||||
|
||||
if (!async && !asyncKeepFileOpen)
|
||||
{
|
||||
throw new InvalidOperationException($"{nameof(asyncKeepFileOpen)} cannot be changed if async is false.");
|
||||
}
|
||||
if (!async && rollOnFileSizeLimit)
|
||||
{
|
||||
throw new InvalidOperationException($"{nameof(rollOnFileSizeLimit)} cannot be changed if async is false.");
|
||||
}
|
||||
|
||||
if (async)
|
||||
{
|
||||
Action<LoggerSinkConfiguration> configure;
|
||||
if (asyncKeepFileOpen)
|
||||
{
|
||||
configure = a => GetFileSink(a);
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is a way to force the file to be closed after each log event. Read more https://github.com/serilog/serilog-sinks-file/issues/99#issuecomment-488612711
|
||||
// We basically map all log events with a AppDomainId property (all events) into a file sink and forces the sink to be closed, due to the sinkMapCountLimit = 0.
|
||||
configure = a => a.Map(AppDomainId, (name,c) => GetFileSink(c), sinkMapCountLimit:0);
|
||||
}
|
||||
|
||||
return configuration.Async(configure, blockWhenFull: asyncBlockWhenFull, bufferSize: asyncBufferSize);
|
||||
|
||||
}
|
||||
return GetFileSink(configuration);
|
||||
return configuration.Async(
|
||||
asyncConfiguration => asyncConfiguration.Map(AppDomainId, (_,mapConfiguration) =>
|
||||
mapConfiguration.File(
|
||||
formatter,
|
||||
path,
|
||||
restrictedToMinimumLevel,
|
||||
fileSizeLimitBytes,
|
||||
levelSwitch,
|
||||
buffered:true,
|
||||
shared:false,
|
||||
flushToDiskInterval,
|
||||
rollingInterval,
|
||||
rollOnFileSizeLimit,
|
||||
retainedFileCountLimit,
|
||||
encoding),
|
||||
sinkMapCountLimit:0)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,13 +20,10 @@
|
||||
<add key="serilog:using:File" value="Umbraco.Core" />
|
||||
<add key="serilog:write-to:File.formatter" value="Serilog.Formatting.Compact.CompactJsonFormatter, Serilog.Formatting.Compact" />
|
||||
<add key="serilog:write-to:File.path" value="%BASEDIR%\App_Data\Logs\UmbracoTraceLog.%MACHINENAME%..json" />
|
||||
<add key="serilog:write-to:File.shared" value="false" />
|
||||
<add key="serilog:write-to:File.buffered" value="true" />
|
||||
<add key="serilog:write-to:File.restrictedToMinimumLevel" value="Debug" />
|
||||
<add key="serilog:write-to:File.retainedFileCountLimit" value="" /> <!-- Number of log files to keep (or remove value to keep all files) -->
|
||||
<add key="serilog:write-to:File.rollingInterval" value="Day" /> <!-- Create a new log file every Minute/Hour/Day/Month/Year/infinite -->
|
||||
<add key="serilog:write-to:File.async" value="true" />
|
||||
<add key="serilog:write-to:File.asyncKeepFileOpen" value="false" />
|
||||
|
||||
|
||||
<!-- Optional TXT log file -->
|
||||
<!--<add key="serilog:using:File" value="Serilog.Sinks.File" /> -->
|
||||
|
||||
Reference in New Issue
Block a user