Skip to content

Instantly share code, notes, and snippets.

@SimonCropp
Created April 21, 2011 05:32
Show Gist options
  • Save SimonCropp/933770 to your computer and use it in GitHub Desktop.
Save SimonCropp/933770 to your computer and use it in GitHub Desktop.
named loggers in NLog
public static class LoggingFactory
{
static LoggingFactory()
{
var name = Assembly.GetEntryAssembly().GetName().Name;
var fileTarget = new FileTarget{FileName = string.Format("${{basedir}}/{0}_${{logger}}.log", name),Layout = "${message}"};
var fileRule = new LoggingRule("*", LogLevel.Debug, fileTarget);
var config = new LoggingConfiguration();
config.LoggingRules.Add(fileRule);
config.AddTarget("file", fileTarget);
LogManager.Configuration = config;
}
public static Logger BuildLogger(string location)
{
return LogManager.GetLogger(location);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment