Forked from imanabu/NLOG app.config AutoRotate7 Days
Created
September 25, 2023 02:51
-
-
Save AvalonWot/fc6590164e34cad86d26ee80b8d26332 to your computer and use it in GitHub Desktop.
NLog Configuration That Auto-Rotate with Config Section
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<configSections> | |
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/> | |
</configSections> | |
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |
<targets> | |
<target name="console" xsi:type="Console" layout="${longdate} ${callsite} ${level} ${message}"/> | |
<target name="logfile" xsi:type="File" fileName="C:\temp\log.txt" layout="${longdate} ${callsite} ${level} ${message}"/> | |
<target name="rotatelog" xsi:type="File" | |
layout="${longdate} ${logger} ${message}" | |
fileName="c:/temp/logs/alogfile.txt" | |
archiveFileName="c:/temp/logs/log.{#}.txt" | |
archiveEvery="Day" | |
archiveNumbering="Rolling" | |
maxArchiveFiles="7" | |
concurrentWrites="true" /> | |
</targets> | |
<rules> | |
<logger name="*" minLevel="Debug" writeTo="rotatelog"/> | |
<logger name="*" minLevel="Debug" writeTo="console"/> | |
</rules> | |
</nlog> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment