Aaron,

Thanks very much. You were right, simply modifying the lockingModel attribute was enough! Both my domains are now logging to the same file, which is exactly what I wanted!

-David

On 2/17/06, Aaron Morton <[EMAIL PROTECTED]> wrote:
David,
I dont think its possible to share loggers or appenders across
AppDomains, log4net stores them in static structures. It they were
shared they would have to be marshal by ref objects, and then one of the
domains would log a lot slower than the other (as it would have to cross
the domain boundry for each call).

I've got different domains using the same config file by defining
loggers at the top of the namespace in each domain, and having them use
different appenders. So if domain 1 only uses classes from
Namespace1(and its descendants) , and domain2 only uses Namespace2

<logger name="Namespace1">
        <appender-ref ref="MyAppender1" />
</logger>
<logger name="Namespace2">
        <appender-ref ref="MyAppender2/>
</logger>

to have the different appenders in each domain write to the same file,
try setting the lockingModel of the RollingFile appender to MinimalLock.
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />

you will probably get by just changing the locking model and not doing
the first step.

aaron

david crunchybear wrote:

> Hi,
>
> After not being able to solve this myself, I'm looking for some sort
> of best practise solution to a problem that I'm facing: My app
> (console app) has 2 appdomains, both of which need to log. In an ideal
> world, they would both log to the same place (in this instance a
> RollingFileAppender) and if there is non-convoluted manner in which to
> do this, that would be great (with both appdomains being given access
> to the same logger). However, if this is not possible, is there any
> other method of achieving something similar that can be recommended?
> If both app domains have to log to different locations, which is
> acceptable. How easy is this to do if both domains are using the same
> conf file? (I have tried this solution using 2 separate appenders with
> 2 separate loggers defined, but I had problems with file locks and
> only one worked!) an example would be great!
>
> Thanks in advance,
>
> -David



Reply via email to