Skip to content

Instantly share code, notes, and snippets.

@chrisortman
Created July 19, 2011 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisortman/1092889 to your computer and use it in GitHub Desktop.
Save chrisortman/1092889 to your computer and use it in GitHub Desktop.
Configure rolling file logging for nlog
SimpleConfigurator.ConfigureForTargetLogging(
new NLog.Targets.FileTarget()
{
FileName = "${specialfolder:MyDocuments}/logs/" + filename + ".${shortdate}.txt",
Layout = new NLog.Layouts.SimpleLayout("${longdate} [${level:uppercase=true}] [${threadid}] ${callsite} - ${message}"),
ArchiveFileName = "${specialfolder:MyDocuments}/logs/archived/" + filename + ".{#####}.txt",
ArchiveAboveSize = 10000000 /* 10 MB */,
ArchiveNumbering = ArchiveNumberingMode.Sequence,
ConcurrentWrites = true,
KeepFileOpen = false,
MaxArchiveFiles = 50,
},
LogLevel.Debug
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment