Lance
Lance

Reputation: 491

Log4net UDP Appender in Windows Service

I have a very simple Windows service developed using TopShelf. I'm using log4net and have a UDP Appender configured. I'm using an app called Log2Console to view the UDP logs.

Everything works fine when I run the app as an exe and I can see the UDP logs in Log2Console. However, when I install the exe as a service using TopShelf and start it I don't see any UDP logs.

I've tried turning off the Windows Firewall to see if that would make a difference but it did not. I've also tried changing the service logon details but no luck there either.

Any suggestions?

Thanks.

Upvotes: 0

Views: 2371

Answers (1)

Vic Alcazar
Vic Alcazar

Reputation: 98

Had a similar issue and had to update the HostFactory set up to include log4net configuration within WhenStarted:

s.WhenStarted(lcp => 
{
   // configure logging for hosted service
   XmlConfigurator.ConfigureAndWatch(new FileInfo(".\\log4net.config"));
   lcp.Start();
});

Upvotes: 1

Related Questions