Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What file name placeholders are available for Serilog?

I use Serilog on a .NET Core application with RollingFile. I wonder, if there are different filename placeholders? I only know {Date}.

For example, I have code like

        Log.Logger = new LoggerConfiguration()
            .MinimumLevel.Information()
            .WriteTo.RollingFile("Logs/{Date}.log")
            .CreateLogger();

Are there any other options for the filename like {Date}? I'd like to have log files by hour.

like image 906
Kim Avatar asked Jun 07 '17 01:06

Kim


People also ask

What is Serilog in c#?

Serilog is a logging library for . NET and C# that allows for more detailed and structured logging than the default . NET logging library. Serilog can be used to log information about application events, errors, and performance metrics.

What is Serilog used for?

Serilog is a . NET library that provides diagnostic logging to files, the console, and almost everywhere you would like. Serilog can be used in classic . NET Framework applications and for applications running on the latest and greatest .

What is Minimumlevel in Serilog?

Serilog defines several levels of log events. From low to high, these are Verbose , Debug , Information , Warning , Error and Fatal . You can set the minimum level you want to log, meaning that events for that level or higher will be logged.


1 Answers

At the time of this writing, Serilog's Rolling File sink supports 3 (three) specifiers:

  • {Date}, which is formatted as yyyyMMdd
  • {Hour}, which is formatted as yyyyMMddHH
  • {HalfHour}, which is formatted as yyyyMMddHHmm

You can see it in the README of the Rolling File sink, as well as in the source code of the Rolling File sink.

like image 93
C. Augusto Proiete Avatar answered Oct 23 '22 15:10

C. Augusto Proiete