Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
04 Debugging log4net.ElasticSearch
If you've done all the proper configuration but you still don't see messages appearing in Elasticsearch, there are some options to debug log4net to see what the problem is.
Text Log File
To get a verbose log of everything log4net is trying to do to start up and log messages, add the below blocks to the appropriate places in your
<configuration> <appSettings> <add key="log4net.Internal.Debug" value="true"/> </appSettings> </configuration>
<configuration> ... <system.diagnostics> <trace autoflush="true"> <listeners> <add name="textWriterTraceListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\temp\log4net.txt" /> </listeners> </trace> </system.diagnostics> ... </configuration>
This will create a log file at
c:\temp\log4net.txt (modify appropriately for your own use) and will list all the debug output from log4net. If there is an issue with your log4net.ElasticSearch configuration or an issue communicating with your Elasticsearch server, the issue should show up there.
If you're using a console app or have built one for basic testing or debug purposes, you can add the following line to your
Main() method or wherever you're instantiating log4net:
log4net.Util.LogLog.InternalDebugging = true;
This will cause debug output to appear in realtime in your console window. If there is an issue in configuration it should show there.