Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force NLog to overwrite the log file

I need NLog to overwrite the log file when the application is restarted. Currently it appends to existing file. For example I have something like this in my NLog.config

<targets>
  <target xsi:type="File" name="fileLog" 
          fileName="${longdate}.log" layout="${message}" />
</targets>

It would be nice if I was able to add to <target> something like this append="false" so instead of appending to existing log it would overwrite.

like image 400
Vadim Avatar asked Nov 28 '12 16:11

Vadim


1 Answers

replace your config section

<targets>
  <target xsi:type="File" name="fileLog" 
          fileName="${longdate}.log" layout="${message}" deleteOldFileOnStartup="true"/>
</targets>
like image 151
burning_LEGION Avatar answered Sep 21 '22 11:09

burning_LEGION