Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions src/Serilog.Sinks.File/FileLoggerConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -528,13 +528,13 @@ static LoggerConfiguration ConfigureFile(

ILogEventSink sink;

if (rollOnFileSizeLimit || rollingInterval != RollingInterval.Infinite)
try
{
sink = new RollingFileSink(path, formatter, fileSizeLimitBytes, retainedFileCountLimit, encoding, buffered, shared, rollingInterval, rollOnFileSizeLimit, hooks, retainedFileTimeLimit);
}
else
{
try
if (rollOnFileSizeLimit || rollingInterval != RollingInterval.Infinite)
{
sink = new RollingFileSink(path, formatter, fileSizeLimitBytes, retainedFileCountLimit, encoding, buffered, shared, rollingInterval, rollOnFileSizeLimit, hooks, retainedFileTimeLimit);
}
else
{
if (shared)
{
Expand All @@ -546,16 +546,17 @@ static LoggerConfiguration ConfigureFile(
{
sink = new FileSink(path, formatter, fileSizeLimitBytes, encoding, buffered, hooks);
}

}
catch (Exception ex)
{
SelfLog.WriteLine("Unable to open file sink for {0}: {1}", path, ex);
}
catch (Exception ex)
{
SelfLog.WriteLine("Unable to open file sink for {0}: {1}", path, ex);

if (propagateExceptions)
throw;
if (propagateExceptions)
throw;

return addSink(new NullSink(), LevelAlias.Maximum, null);
}
return addSink(new NullSink(), LevelAlias.Maximum, null);
}

if (flushToDiskInterval.HasValue)
Expand Down