Skip to content

Instantly share code, notes, and snippets.

@ilivewithian
Last active January 3, 2018 12:02
Show Gist options
  • Save ilivewithian/6bf8c0e841456e2431645cfba9629c07 to your computer and use it in GitHub Desktop.
Save ilivewithian/6bf8c0e841456e2431645cfba9629c07 to your computer and use it in GitHub Desktop.
Simple Log4Net Config
public static class Logger
{
public static ILog Create()
{
var hierarchy = (Hierarchy)LogManager.GetRepository(typeof(Logger).Assembly);
hierarchy.Root.RemoveAllAppenders();
var pl = new PatternLayout();
pl.ConversionPattern = "%d [%t] %-5p %m%n";
pl.ActivateOptions();
var consoleAppender = new ConsoleAppender();
consoleAppender.Layout = pl;
consoleAppender.ActivateOptions();
BasicConfigurator.Configure(hierarchy, consoleAppender);
return LogManager.GetLogger(typeof(Logger));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment