diff --git a/README.md b/README.md
index 8efce0f..368518b 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,6 @@
-# Serilog.Sinks.RollingFile
+# Serilog.Sinks.RollingFile [](https://ci.appveyor.com/project/serilog/serilog-sinks-rollingfile) [](https://www.nuget.org/packages/Serilog.Sinks.RollingFile/) [](https://github.com/serilog/serilog/wiki) [](https://gitter.im/serilog/serilog)
-The rolling file sink for Serilog.
-
-[](https://ci.appveyor.com/project/serilog/serilog-sinks-rollingfile) [](https://www.nuget.org/packages/Serilog.Sinks.RollingFile/)
-
-Writes log events to a set of text files, one per day.
+Writes [Serilog](https://serilog.net) events to a set of text files, one per day.
The filename can include the `{Date}` placeholder, which will be replaced with the date of the events contained in the file.
@@ -28,6 +24,4 @@ For the same reason, only **the most recent 31 files** are retained by default (
> **Important:** Only one process may write to a log file at a given time. For multi-process scenarios, either use separate files or one of the non-file-based sinks.
-* [Documentation](https://github.com/serilog/serilog/wiki)
-
-Copyright © 2016 Serilog Contributors - Provided under the [Apache License, Version 2.0](http://apache.org/licenses/LICENSE-2.0.html).
+_Copyright © 2016 Serilog Contributors - Provided under the [Apache License, Version 2.0](http://apache.org/licenses/LICENSE-2.0.html)._
diff --git a/src/Serilog.Sinks.RollingFile/Properties/AssemblyInfo.cs b/src/Serilog.Sinks.RollingFile/Properties/AssemblyInfo.cs
index 1237c0e..873d91a 100644
--- a/src/Serilog.Sinks.RollingFile/Properties/AssemblyInfo.cs
+++ b/src/Serilog.Sinks.RollingFile/Properties/AssemblyInfo.cs
@@ -6,7 +6,7 @@
[assembly: CLSCompliant(true)]
-[assembly: InternalsVisibleTo("Serilog.Tests, PublicKey=" +
+[assembly: InternalsVisibleTo("Serilog.Sinks.RollingFile.Tests, PublicKey=" +
"0024000004800000940000000602000000240000525341310004000001000100fb8d13fd344a1c" +
"6fe0fe83ef33c1080bf30690765bc6eb0df26ebfdf8f21670c64265b30db09f73a0dea5b3db4c9" +
"d18dbf6d5a25af5ce9016f281014d79dc3b4201ac646c451830fc7e61a2dfd633d34c39f87b818" +
diff --git a/src/Serilog.Sinks.RollingFile/RollingFileLoggerConfigurationExtensions.cs b/src/Serilog.Sinks.RollingFile/RollingFileLoggerConfigurationExtensions.cs
index b6a6e10..672e4ef 100644
--- a/src/Serilog.Sinks.RollingFile/RollingFileLoggerConfigurationExtensions.cs
+++ b/src/Serilog.Sinks.RollingFile/RollingFileLoggerConfigurationExtensions.cs
@@ -16,11 +16,15 @@
using Serilog.Configuration;
using Serilog.Core;
using Serilog.Events;
+using Serilog.Formatting;
using Serilog.Formatting.Display;
using Serilog.Sinks.RollingFile;
namespace Serilog
{
+ ///
+ /// Extends with rolling file configuration methods.
+ ///
public static class RollingFileLoggerConfigurationExtensions
{
const int DefaultRetainedFileCountLimit = 31; // A long month of logs
@@ -62,9 +66,46 @@ public static LoggerConfiguration RollingFile(
LoggingLevelSwitch levelSwitch = null,
bool buffered = false)
{
- if (sinkConfiguration == null) throw new ArgumentNullException(nameof(sinkConfiguration));
- if (outputTemplate == null) throw new ArgumentNullException(nameof(outputTemplate));
var formatter = new MessageTemplateTextFormatter(outputTemplate, formatProvider);
+ return RollingFile(sinkConfiguration, formatter, pathFormat, restrictedToMinimumLevel, fileSizeLimitBytes,
+ retainedFileCountLimit, levelSwitch, buffered);
+ }
+
+ ///
+ /// Write log events to a series of files. Each file will be named according to
+ /// the date of the first log entry written to it. Only simple date-based rolling is
+ /// currently supported.
+ ///
+ /// Logger sink configuration.
+ /// Formatter to control how events are rendered into the file. To control
+ /// plain text formatting, use the overload that accepts an output template instead.
+ /// String describing the location of the log files,
+ /// with {Date} in the place of the file date. E.g. "Logs\myapp-{Date}.log" will result in log
+ /// files such as "Logs\myapp-2013-10-20.log", "Logs\myapp-2013-10-21.log" and so on.
+ /// The minimum level for
+ /// events passed through the sink. Ignored when is specified.
+ /// A switch allowing the pass-through minimum level
+ /// to be changed at runtime.
+ /// The maximum size, in bytes, to which any single log file will be allowed to grow.
+ /// For unrestricted growth, pass null. The default is 1 GB.
+ /// The maximum number of log files that will be retained,
+ /// including the current log file. For unlimited retention, pass null. The default is 31.
+ /// Indicates if flushing to the output file can be buffered or not. The default
+ /// is false.
+ /// Configuration object allowing method chaining.
+ /// The file will be written using the UTF-8 character set.
+ public static LoggerConfiguration RollingFile(
+ this LoggerSinkConfiguration sinkConfiguration,
+ ITextFormatter formatter,
+ string pathFormat,
+ LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
+ long? fileSizeLimitBytes = DefaultFileSizeLimitBytes,
+ int? retainedFileCountLimit = DefaultRetainedFileCountLimit,
+ LoggingLevelSwitch levelSwitch = null,
+ bool buffered = false)
+ {
+ if (sinkConfiguration == null) throw new ArgumentNullException(nameof(sinkConfiguration));
+ if (formatter == null) throw new ArgumentNullException(nameof(formatter));
var sink = new RollingFileSink(pathFormat, formatter, fileSizeLimitBytes, retainedFileCountLimit, buffered: buffered);
return sinkConfiguration.Sink(sink, restrictedToMinimumLevel, levelSwitch);
}
diff --git a/src/Serilog.Sinks.RollingFile/project.json b/src/Serilog.Sinks.RollingFile/project.json
index 60159f2..0a191b0 100644
--- a/src/Serilog.Sinks.RollingFile/project.json
+++ b/src/Serilog.Sinks.RollingFile/project.json
@@ -13,7 +13,9 @@
"Serilog.Sinks.File": "2.0.0"
},
"buildOptions": {
- "keyFile": "../../assets/Serilog.snk"
+ "keyFile": "../../assets/Serilog.snk",
+ "xmlDoc": true,
+ "warningsAsErrors": true
},
"frameworks": {
"net4.5": {},
diff --git a/test/Serilog.Sinks.RollingFile.Tests/Sinks/RollingFile/RollingFileSinkTests.cs b/test/Serilog.Sinks.RollingFile.Tests/RollingFileSinkTests.cs
similarity index 90%
rename from test/Serilog.Sinks.RollingFile.Tests/Sinks/RollingFile/RollingFileSinkTests.cs
rename to test/Serilog.Sinks.RollingFile.Tests/RollingFileSinkTests.cs
index 38f054c..1b032e1 100644
--- a/test/Serilog.Sinks.RollingFile.Tests/Sinks/RollingFile/RollingFileSinkTests.cs
+++ b/test/Serilog.Sinks.RollingFile.Tests/RollingFileSinkTests.cs
@@ -1,14 +1,13 @@
-#if FILE_IO && INTERNAL_TESTS
-
-using System;
+using System;
using System.Collections.Generic;
using System.IO;
using Xunit;
+using Serilog;
using Serilog.Events;
using Serilog.Sinks.RollingFile;
using Serilog.Tests.Support;
-namespace Serilog.Tests.Sinks.RollingFile
+namespace Serilog.Sinks.RollingFile.Tests
{
public class RollingFileSinkTests
{
@@ -37,9 +36,9 @@ public void WhenRetentionCountIsSetOldFilesAreDeleted()
files =>
{
Assert.Equal(3, files.Count);
- Assert.True(!File.Exists(files[0]));
- Assert.True(File.Exists(files[1]));
- Assert.True(File.Exists(files[2]));
+ Assert.True(!System.IO.File.Exists(files[0]));
+ Assert.True(System.IO.File.Exists(files[1]));
+ Assert.True(System.IO.File.Exists(files[2]));
});
}
@@ -99,7 +98,7 @@ static void TestRollingEventSequence(
log.Write(@event);
var expected = pathFormat.Replace("{Date}", @event.Timestamp.ToString("yyyyMMdd"));
- Assert.True(File.Exists(expected));
+ Assert.True(System.IO.File.Exists(expected));
verified.Add(expected);
}
@@ -113,4 +112,3 @@ static void TestRollingEventSequence(
}
}
}
-#endif
diff --git a/test/Serilog.Sinks.RollingFile.Tests/Sinks/RollingFile/TemplatedPathRollerTests.cs b/test/Serilog.Sinks.RollingFile.Tests/TemplatedPathRollerTests.cs
similarity index 98%
rename from test/Serilog.Sinks.RollingFile.Tests/Sinks/RollingFile/TemplatedPathRollerTests.cs
rename to test/Serilog.Sinks.RollingFile.Tests/TemplatedPathRollerTests.cs
index 5e03327..6bc4083 100644
--- a/test/Serilog.Sinks.RollingFile.Tests/Sinks/RollingFile/TemplatedPathRollerTests.cs
+++ b/test/Serilog.Sinks.RollingFile.Tests/TemplatedPathRollerTests.cs
@@ -1,12 +1,10 @@
-#if INTERNAL_TESTS
-
-using System;
+using System;
using System.IO;
using System.Linq;
using Xunit;
using Serilog.Sinks.RollingFile;
-namespace Serilog.Tests.Sinks.RollingFile
+namespace Serilog.Sinks.RollingFile.Tests
{
public class TemplatedPathRollerTests
{
@@ -129,4 +127,3 @@ public void MatchingParsesDates()
}
}
-#endif
diff --git a/test/Serilog.Sinks.RollingFile.Tests/project.json b/test/Serilog.Sinks.RollingFile.Tests/project.json
index 005c657..1f84c3e 100644
--- a/test/Serilog.Sinks.RollingFile.Tests/project.json
+++ b/test/Serilog.Sinks.RollingFile.Tests/project.json
@@ -7,6 +7,10 @@
"dotnet-test-xunit": "1.0.0-rc2-build10025",
"Serilog.Sinks.File": "2.0.0"
},
+ "buildOptions": {
+ "keyFile": "../../assets/Serilog.snk",
+ "warningsAsErrors": true
+ },
"frameworks": {
"net4.5.2": {},
"netcoreapp1.0": {