Skip to content

Commit c9f5c7c

Browse files
committed
Moved sample code from Uncyclo [Skip CI]
1 parent 098cd34 commit c9f5c7c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,29 @@ The file sink for Serilog.
44

55
[![Build status](https://ci.appveyor.com/api/projects/status/hh9gymy0n6tne46j?svg=true)](https://ci.appveyor.com/project/serilog/serilog-sinks-file) [![NuGet Version](http://img.shields.io/nuget/v/Serilog.Sinks.File.svg?style=flat)](https://www.nuget.org/packages/Serilog.Sinks.File/)
66

7+
8+
Writes log events to a text file.
9+
10+
```csharp
11+
var log = new LoggerConfiguration()
12+
.WriteTo.File("log.txt")
13+
.CreateLogger();
14+
```
15+
16+
To avoid sinking apps with runaway disk usage the file sink **limits file size to 1GB by default**. The limit can be increased or removed using the `fileSizeLimitBytes` parameter.
17+
18+
```csharp
19+
.WriteTo.File("log.txt", fileSizeLimitBytes: null)
20+
```
21+
22+
Or in XML [app-settings format](https://github.com/serilog/serilog/wiki/AppSettings):
23+
24+
```xml
25+
<add key="serilog:write-to:File.path" value="log.txt" />
26+
```
27+
28+
> **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.
29+
730
* [Documentation](https://github.com/serilog/serilog/wiki)
831

932
Copyright &copy; 2016 Serilog Contributors - Provided under the [Apache License, Version 2.0](http://apache.org/licenses/LICENSE-2.0.html).

0 commit comments

Comments
 (0)