Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why wont my log4net log entries show up in Chainsaw on Windows 7

I'm trying to get log4net to log via udp to chainsaw but its not working on windows 7. My config files are as follows:

  <log4net debug="true">
<appender name="trace" type="log4net.Appender.TraceAppender, log4net">
  <layout type="log4net.Layout.PatternLayout,log4net">
    <param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" />
  </layout>
</appender>
<appender name="UdpAppender" type="log4net.Appender.UdpAppender">
    <remoteAddress value="127.0.0.1" />
    <remotePort value="8085" />
    <layout type="log4net.Layout.XmlLayoutSchemaLog4j">
      <locationInfo value="true" />
    </layout>
</appender>
<root>
  <level value="TRACE" />
  <appender-ref ref="trace" />
  <appender-ref ref="UdpAppender" />
</root>

my chainsaw config file looks like this:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> 
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">    
    <plugin name="UDPReceiver" class="org.apache.log4j.net.UDPReceiver">
        <param name="Port" value="8085" />
    </plugin>    
</log4j:configuration>

All of this is per the documentation found in: http://logging.apache.org/log4net/release/howto/chainsaw.html

Yet none of the logs show up.

like image 777
Matthew Tschiegg Avatar asked Jan 02 '12 19:01

Matthew Tschiegg


1 Answers

Figured it out. Looks like log4net has issues with ipv6 and windows 7. To get around these issues you need to add an entry into your host file that looks like this:

    127.0.0.2       localhosttwo

then your UpdAppender needs to reference that DNS entry as so:

 <remoteAddress value="localhosttwo" />

127.0.0.2 is the ipv6 address for your localmachine and you need an explcit dns entry or else log4net will throw an error if you try and use the numerical address in the config file.

Make sure to flush your dns after you change the hostfile

like image 52
Matthew Tschiegg Avatar answered Nov 15 '22 10:11

Matthew Tschiegg