4

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>
Bergi
  • 630,263
  • 148
  • 957
  • 1,375
WebMonster
  • 2,981
  • 2
  • 22
  • 29

2 Answers2

1

Here's an archive of someone with similar issues using the log4net udp appender: http://www.mail-archive.com/log4net-user@logging.apache.org/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
  • 1,728
  • 11
  • 11
1

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: Log4Net works on Dev machine, fails when deployed to shared host (using same db/connstring) to troubleshoot any further problems.

Community
  • 1
  • 1
Gyuri
  • 4,548
  • 4
  • 34
  • 44