views:

37

answers:

2

I would like to use log4net's UdpAppender with Apache Chainsaw to log messages from my ASP.NET web application. I followed instructions on log4net's website, but no Udp packets are sent (firewall is turned off, and I tried to monitor my machine with TcpView - no udp packets were generated at all; other appenders re working). Log4net debug doesn't give any errors, UdpAppender gets added to loggers. I don't know what I am missing.

My config file is:

<log4net debug="true">
  <renderer renderingClass="Logging.HttpContextRenderer" renderedClass="System.Web.HttpContext" />
  <appender name="UdpAppender" type="log4net.Appender.UdpAppender">
    <localPort value="8080" />
    <remoteAddress value="127.0.0.1" />
    <remotePort value="8080" />
    <layout type="log4net.Layout.XmlLayoutSchemaLog4j">
      <locationInfo value="true" />
    </layout>
  </appender>
 <root>
    <priority value="ALL"/>
    <appender-ref ref="UdpAppender"/>
  </root>
</log4net>
A: 

Here's an archive of someone with similar issues using the log4net udp appender: http://www.mail-archive.com/[email protected]/msg03906.html

You can use Chainsaw V2 with a regular text file if that would be easier (using VFSLogFilePatternReceiver).

A new version of Chainsaw will be released shortly with a lot of enhancements. A pre-release version and screen shot are available here:

http://people.apache.org/~sdeboy/

Scott
A: 

I also had the same problem and found that removing the

<localPort value="8080" />

solved it.

I tested the appender using the example on the log4net UdpAppender page: http://logging.apache.org/log4net/release/sdk/log4net.Appender.UdpAppender.html

but I had to change the line

IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, 0);

to

IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, 8080);

If you use this, you can simply rewrite the received messages to a rolling logfile using log4net and I believe Chainsaw can read that.

This might work as well: http://devintelligence.com/log4netviewer/

If this doesn't work, you can debug log4net, or use the internal logger mechanism mentioned in this article: http://stackoverflow.com/questions/3542581/log4net-works-on-dev-machine-fails-when-deployed-to-shared-host-using-same-db-c to troubleshoot any further problems.

Gyuri