Why are my log4net log entries displayed in Chainsaw on Windows 7

I am trying to get log4net to register through udp for a chainsaw but it doesn’t work on Windows 7. My configuration files look like this:

<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 configuration file is as follows:

 <?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 this matches the documentation found at: http://logging.apache.org/log4net/release/howto/chainsaw.html

However, no logs are displayed.

+6
source share
1 answer

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

  127.0.0.2 localhosttwo 

then your UpdAppender should reference this DNS record as follows:

  <remoteAddress value="localhosttwo" /> 

127.0.0.2 is the ipv6 address for your local machine, and you need the explcit dns entry, otherwise log4net throws an error if you try to use a numerical address in the configuration file.

Make sure you reset your dns after changing the host file

+5
source

Source: https://habr.com/ru/post/904933/


All Articles