04 Debugging log4net.ElasticSearch

JP Toto edited this page Jan 30, 2016 · 1 revision

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 App.config or Web.config files:

<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.

StdOut Debug

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.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.