Created
October 10, 2017 14:54
-
-
Save xtrmstep/b02a6da3f54aa6d40ed62e50096e10d6 to your computer and use it in GitHub Desktop.
log4net snippets
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
// variable declaration | |
private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | |
// You have several options to make it alive | |
// 1) AssemblyInfo.cs | |
[assembly: log4net.Config.XmlConfigurator(Watch = true)] | |
// 2) manual kick in the beginning of program execution | |
XmlConfigurator.Configure(); |
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
<configuration> | |
<configSections> | |
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /> | |
</configSections> | |
<startup> | |
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> | |
</startup> | |
<log4net> | |
<appender name="FileAppender" type="log4net.Appender.RollingFileAppender"> | |
<file value="d:\logs\data.log" /> | |
<rollingStyle value="Once" /> | |
<maxSizeRollBackups value="10" /> | |
<layout type="log4net.Layout.PatternLayout"> | |
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline%exception" /> | |
</layout> | |
</appender> | |
<root> | |
<level value="All" /> | |
<appender-ref ref="FileAppender" /> | |
</root> | |
</log4net> | |
</configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment