Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serilog - path to log file

i am trying to start working with serilog. The normal RollingFile doesn't fit my needs (i need the counting like logs\20160701-00002.txt), so i want to use the RollingFileAlternate as a sink.

When using RollingFile i added

  loggerInstance = new LoggerConfiguration()
                    .ReadFrom.AppSettings()

and was able to get the path from the App.config file with using:

  <add key="serilog:minimum-level" value="Debug" />
  <add key="serilog:using:RollingFile" value="Serilog.Sinks.RollingFile" />
  <add key="serilog:write-to:RollingFile.pathFormat" value="..\Log\MyLOG.LOG" />

Now i switched to RollingFileAlternate :

        <add key="serilog:minimum-level" value="Debug" />
        <add key="serilog:using:RollingFileAlternate" value="Serilog.Sinks.RollingFileAlternate" />
        <add key="serilog:write-to:RollingFileAlternate.logsDirectory" value="..\Log\test.log" />
        <add key="serilog:write-to:RollingFileALternate.logsFolder" value="..\Log" />

I tried using logsDirectory and logsFolder since both are described in the examples of https://github.com/BedeGaming/sinks-rollingfile but my program won't create a file.

if I add to the Loggerconfiguration:

        loggerInstance = new LoggerConfiguration()
            .ReadFrom.AppSettings()
            .WriteTo.RollingFileAlternate("..\\log")

the foldername will be used and the logfiles are put in this folder.

Can some one help me and tell me what i am missing?

like image 446
Monika_Aydt Avatar asked Dec 19 '16 14:12

Monika_Aydt


1 Answers

There may be a problem with the documentation; the argument is called logDirectory, not logsDirectory. So, you need:

<add key="serilog:write-to:RollingFileAlternate.logDirectory" value="..\Log" />
like image 103
Nicholas Blumhardt Avatar answered Oct 05 '22 07:10

Nicholas Blumhardt