views:

336

answers:

3

I have an application which initializes log4net from one appdomain and needs to use it in another appdomain. Is it supported?

If not, should I initialize log4net from each appdomain? Is there a risk in multiple initializations in the same application? Should I use the same log4net.config?

+2  A: 

The logger should be initialized once per app-domain.

Darin Dimitrov
+1  A: 

Agree with darin, once per app domain. If you're looking to have these applications use consolidated logging, you'll want to choose a logging target that won't be subject to contention (i.e. not FileAppender or RollingFileAppender).

Thomas Beck
+2  A: 

The log4net-user mailing list has an answer that works with RollingFileAppender. Add the following line to the appender in log4net.config:

<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
Michael L Perry