This project has moved and is read-only. For the latest updates, please go here.

Sentinel not working with Log4net UDP appender

May 11, 2011 at 9:23 PM

I have properly configured Log4Net on my project (ASP.NET and class library). I set the application to act as producer on port 8023 and set the receiver (sentinel) as I have additionally let port 8024 open in the Kaspersky Internet Security for inbound connections.

When I use the Rolling file appender I see all my log output but then I have to use WinTail because Sentinel does not support monitoring files. When I set the application to use the UDP appender as configured, absolutely nothing shows up on Sentinel regardless of the filter.

I configured sentinel using the wizard for Log4Net Network Provider, set the ports appropriately but nothing. Disappointing, I was hoping to use this to debug my ASP.NET application.

Also noticed that it is not possible to save configurations in Sentinel :(

Is this project dead? don't see much activity here, would be a pity because it really looks nice. I only need to get it to work in my configuration.

May 12, 2011 at 5:16 AM

I re-checked my firewall but it was ok. I found another viewer (Log2Console) right here on CodePlex. It isn't as nice looking but with it I got the UDP appender of log4net to work out of the box without much fiddling. I figured perhaps I had done something wrong (or right?) and decided to try SEntinel with the same configuration I used in Log2Console and the web application. Unfortunately the result was the same, no log messages shown.

So I am almost sure there is something wrong but hope somebody can help getting it resolved, I want to get Sentinel working before I write my article.

BTW Sentinel seems to forget the configuration, everytime I have to configure the provider.

May 12, 2011 at 9:31 AM
Edited May 12, 2011 at 9:32 AM
Whilst Sentinel isn't dead, I am spending all of my time on my day job for which Sentinel was, as you mention, for debugging and monitoring of it.
What configuration file are you using for log4net?  I ask because your title says "UDP appender" and your detail later says "network provider".  
In the source, my test application uses "log4net.Appender.UdpAppender". Is that what you're using?
Sentinel has, since about 0.9, supported monitoring of files directly, but this isn't recommended because there is no standard 'output' from log4net and nLog (e.g. both can be changed) and thus parsing a file isn't as easy as I'd like.  At the moment you need to supply a .NET regular expression with matching groups that correspond to the column names - not idea and this is why I'd probably warn most people off until I improve it considerably (or someone else does).
Regarding your other comment about forgetting configuration, this is acknowledged and a small work-around was recently introduced where you can supply the configuration on the command line.  This works quite well in non-dynamic environments.
May 13, 2011 at 5:51 PM

Yes I use the log4net.Appender.UdpAppender. Here is my web.config parts relevant to the configuration:

    <appender name="UdpAppender" type="log4net.Appender.UdpAppender">
      <localPort value="8023" />
      <remoteAddress value="" />
      <remotePort value="8025" />
      <layout type="log4net.Layout.PatternLayout, log4net">
        <conversionPattern value="%-5level %logger [%property{NDC}] - %message%newline" />
    <appender name="UdpAppenderLog2" type="log4net.Appender.UdpAppender">
      <remoteAddress value="localhost" />
      <remotePort value="8025" />
      <layout type="log4net.Layout.XmlLayoutSchemaLog4j" />
      <level value="All"/>
      <appender-ref ref="UdpAppenderLog2" />
      <!-- <appender-ref ref="RollingLogFileAppender" /> -->
      <!-- <appender-ref ref="UdpAppender" /> -->

I mentioned network provider because every time I start Sentinel up it asks me to reconfigure (can get tiresome, can't seem to save it anywhere).

FIrst it asks for a name of some kind, then to select and name provider and I choose "log4net Network Provider" (that's what I was referring to). Then I select UDP (TCP is there but disabled).
I enter port 8025 which is the remote port (log watcher) I configured in web.config.

I tried both UdpAppenderLog2 and UdpAppender with Sentinel but in both cases I received no log messages. The messages are being sent by the application because I see them if I use a
rolling file appender with WinTail or use the Udp Appenders with Log2Console.

Would be great to get Sentinel working because my web.config is correct and the values I enter in the config wizard are good. Any ideas?

May 14, 2011 at 9:00 AM

Whilst Sentinel doesn't "save" your session settings, you can set them on the command line and not be shown the wizard.  This effectively does the same thing as you want.

May 14, 2011 at 9:02 AM

Could you try changing to - newer machines with multiple protocols (eg. IPv6 and multiple network cards) seem to prefer that number
rather than - it's not a condition I have met but others have.

May 14, 2011 at 9:08 AM

Try changing the layout to 'log4net.Layout.XmlLayout' as documented.  <-- this is possibly the cause as I parse the recieved XML message to establish the content.

Try removing the 'localPort' setting as it isn't needed.

TCP is disabled for log4net as it doesn't have a TcpAppender unlike nLog.

Could you also try getting the source (at the very least to the one project) where you find a Log4NetTester that simply generates test messages.

May 16, 2011 at 2:21 AM

Well I know Log4Net is working, otherwise I wouldn't be getting any log messages on the RollingFileAppender or UdpAppender (working with Log2Console).

However, I did make the changes you hinted (remove localport, use Xmllayout, the .0.2 address) and this is what I got:

<appender name="UdpAppender" type="log4net.Appender.UdpAppender">
      <remoteAddress value="" />
      <remotePort value="8025" />
      <layout type="log4net.Layout.XmlLayout" />

With this configuration reflecting the changes you indicated as necessary (or probably) it actually WORKED (Thanks a million!). I am curious about the address setting though,
I use Windows 7 Home Premium 64-bits and when I use Sentinel with .0.0.1 no messages arrive to Sentinel (but they do at Log2Console), if I change it to 0.0.2 then Sentinel
receives the messages (haven't tried with Log2Console using that address).

Also, any plans to support the PatternLayout any time soon? I usually have the %M (Method) in my pattern layout for Debug. Also the saving (or remembering of last
configuration as Log2Console does would be nice) In the meantime will look at the docs to find the command line settings.

Anyway, I can use Sentinel now which is just great, I hope this tool continues evolving. And again, thanks for the help!

May 16, 2011 at 6:53 AM

Because Sentinel isn't directly linked to your log4net configuration, it has no idea what "structure" you're sending your data to it in.  This is why, for log4net I selected the UdpAppender as it sends XML structured data which is easy to parse.  

If the 'method' value is in the data then making it possible to be shown is quite easy.  I'd need to take a look.

Regarding the 0.0.2 issue, it is something others have commented upon that I'm not 100% certain of and been unable to reproduce.  I believe it is related to IPv6 vs IPv4 issues which, with Windows 7, defaults to IPv6 first - I will see whether a bug has been raised.