logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Morten Andersen <mor...@vianett.no>
Subject Re: Appenders and AppDomains
Date Sat, 15 Jul 2006 10:07:19 GMT
Thanks Nicko. The remoting solution sounds interesting. Is this a fast 
and reliable solution if you compere it to a RollingFileAppender?

When I run BasicConfigurator.Configure() in one or more appdomain the 
log messages for the domain will be printed in the output window in 
vs.net. Is this using the MarshalByRef solution?

Is it best to have one remotingserver for all my hwservers and 
applications, or should I have one remotingserver for each hwserver?

- Morten

Nicko Cadell wrote:
> AppDomains are logical isolation units akin to lightweight processes.
> log4net cannot exist outside an AppDomain because nothing can exist
> outside an AppDomain. log4net must be configured in each AppDomain, and
> it know nothing about the appenders or configuration in the other
> AppDomains. Each AppDomain will have its own logger hierarchy and root
> logger.
>
> It is quite a challenge to find all the AppDomains in the process and
> hook them up.
>
> There are 2 different approaches that I can think of:
>
> 1) Create a MarshalByRef appender implementation, i.e. a class that
> extends MarshalByRefObject and implements the IAppender interface. This
> could just be a simple wrapper that forwards the call to another
> IAppender, allowing you to reuse the existing appenders. 
> This appender and the MarshalByRef appender wrapper would need to be
> created in only 1 AppDomain. You would then need to get a reference to
> this wrapper via remoting into each of the other AppDomains and then
> attach that appender reference to the root logger in that AppDomain.
>
> 2) The other approach is similar in that it still requires remoting, but
> rather than marshalling the appender across and attaching it to the
> logger hierarchy in all the AppDomains, the events logged in the
> AppDomains are sent via remoting to a single published listener which
> re-logs the event it its AppDomain. This allows the logging events to be
> centralised in a single AppDomain, but they can still be logged in their
> own AppDomains.
> To do this you will need to use the RemotingAppender in each of your
> AppDomains. The RemotingAppender will sent the LoggingEvent via .NET
> remoting to a published listener. The RemoteLoggingServerPlugin is a
> built-in way of publishing a listener. See the Remoting examples in the
> log4net download, examples\net\1.0\Remoting. In your case rather than
> running separate processes, one of your AppDomains will be the server
> (and receive logging events) and all the other AppDomains will be the
> clients.
>
> Cheers,
> Nicko
>
>   
>> -----Original Message-----
>> From: Morten Andersen [mailto:morten@vianett.no] 
>> Sent: 14 July 2006 14:30
>> To: Log4NET User
>> Subject: Appenders and AppDomains
>>
>> Hi
>>
>> Is it possible to have one appender for all app domains in a process? 
>> Each app domain has its own appender, but I also want a 
>> global appender for all domains.
>>
>> - Morten
>>
>>
>>     
>
>   

Mime
View raw message