Nlog: Multiple file created when using minutes and seconds in fileName

Created on 18 Oct 2019  路  3Comments  路  Source: NLog/NLog

Actually I was searching for a while in your documentation and I couldn't see anywhere the answer to my question.

I got a console program in .net core 3.0. (Anyway because the case can be reproduced in Framework too).

The logger will create a new file every different second you want to log something.

I got this config :

  <targets>
    <target 
      name="logfile" 
      xsi:type="File" 
      fileName="${basedir}/Logs/Log_${date:format=yyyyMMddHH\:mm\:ss}.log"
      keepFileOpen="true"
      layout="${date:format=dddd dd MMMM yyyy HH\:mm\:ss:culture=Fr} - ${message}"/>
  </targets>

  <rules>
    <logger name="*" minlevel="Debug" writeTo="logfile" />
  </rules>

Example :
Program start at 10h00m00s : wants to log "start" then Log_2019101810_00_00.log is created.
Program end at 10h00m10s: wants to log "end" then Log_2019101810_00_10.log is created.

What I want is to use the same file during all program.

Is there any attribute to indicate what I want ?

Thanks

file-archiving file-target question

Most helpful comment

You could use https://github.com/NLog/NLog/wiki/Cached-Layout-Renderer for that. See also the last example on that page :)

All 3 comments

Hi! Thanks for opening your first issue here! Please make sure to follow the issue template - so we could help you better!

You could use https://github.com/NLog/NLog/wiki/Cached-Layout-Renderer for that. See also the last example on that page :)

That is exactly what I was looking for.
Thanks a lot !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

npandrei picture npandrei  路  3Comments

haythamabutair picture haythamabutair  路  3Comments

vasumsit picture vasumsit  路  3Comments

ErcinDedeoglu picture ErcinDedeoglu  路  3Comments

FaMouZx3 picture FaMouZx3  路  3Comments