Created
February 2, 2015 14:08
-
-
Save jptoto/fa22ffcb351966711447 to your computer and use it in GitHub Desktop.
log4net testing
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
<?xml version="1.0" encoding="utf-8" ?> | |
<configuration> | |
<configSections> | |
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /> | |
</configSections> | |
<startup> | |
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" /> | |
</startup> | |
<log4net> | |
<appender name="ElasticSearchAppender" type="log4net.ElasticSearch.ElasticSearchAppender, log4net.ElasticSearch"> | |
<layout type="log4net.Layout.PatternLayout,log4net"> | |
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p %c{1}:%L - %m%n" /> | |
</layout> | |
<connectionString value="Server=localhost;Index=log;Port=9200;rolling=true"/> | |
<lossy value="false" /> | |
<bufferSize value="100" /> | |
<evaluator type="log4net.Core.LevelEvaluator"> | |
<threshold value="ALL"/> | |
</evaluator> | |
</appender> | |
<root> | |
<level value="ALL"/> | |
<appender-ref ref="ElasticSearchAppender" /> | |
</root> | |
</log4net> | |
<appSettings> | |
<add key="log4net.Internal.Debug" value="true"/> | |
</appSettings> | |
<system.diagnostics> | |
<trace autoflush="true"> | |
<listeners> | |
<add | |
name="textWriterTraceListener" | |
type="System.Diagnostics.TextWriterTraceListener" | |
initializeData="C:\temp\log4net.txt" /> | |
</listeners> | |
</trace> | |
</system.diagnostics> | |
</configuration> |
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
class Program | |
{ | |
private static readonly ILog _log = LogManager.GetLogger(typeof(Program)); | |
static void Main(string[] args) | |
{ | |
try | |
{ | |
var z = decimal.Divide(10, 0); | |
} | |
catch (Exception ex) | |
{ | |
_log.Error(ex); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment