Tuesday, January 11, 2011

How to make Log4Net to work with a Windows Service assembly?

There are 2 main concerns with using Log4Net with Windows Service:

1. XmlConfigurator must have its Watch property set to true
2. The output log file must be written to a folder where the service user has writing rights

To solve this you can add this line to your AssemblyInfo.cs:

[assembly: log4net.Config.XmlConfigurator(Watch = true)]

And you have to choose a suitable output path such as:

<file value="${ALLUSERSPROFILE}\Company\Product.log" />

1 comment:

Leslie Lim said...

I read your blog.I thought it was great.. Hope you have a great day. God bless.

Rica
www.imarksweb.org