logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicko Cadell" <ni...@neoworks.com>
Subject RE: Appenders and AppDomains
Date Sun, 16 Jul 2006 22:25:25 GMT

> -----Original Message-----
> From: Morten Andersen [mailto:morten@vianett.no] 
> Sent: 15 July 2006 11:07
> To: Log4NET User
> Subject: Re: Appenders and AppDomains
> Thanks Nicko. The remoting solution sounds interesting. Is 
> this a fast and reliable solution if you compere it to a 
> RollingFileAppender?

.NET remoting is as reliable as the transport it runs over. If it using
the SMTP protocol [1] then its reliability depends on the mail servers
and how much disk space they have.

Between AppDomains in the same process the remoting calls should be 100%
reliable (assuming that the host machine is responsive and able to
schedule threads).

The intra AppDomain remoting transport is very fast, but remember that
your still have to cost of logging after remoting the event. I have not
done any performance analysis of this scenario so you may want to put
together some tests of your own. The perfromance depends on the remoting
transport selected.


> 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?

Which log messages do you mean? Internal ones from log4net or ones from
a log4net appender? What appender are you  using? If you mean the
MarshalByRef solution I outlined in my previous mail, then no as this
has not been implemented.

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

Again this is a difficult question to answer without knowing your
architecture. If you are going to use remoting to centralise your
logging events you will need to have a way of identifying your logging
server. You will need to select your remoting transport (in memory cross
AppDomain, TCP, other...) and then decide how your are going to identify
the server. TCP transport requires a running server and known port (and
you can only have 1 server instance bound to a single known port). Cross
AppDomain requires a transparent proxy, which you can create using the
Activator.CreateInstance methods (but may not be easy).

So this depends on your architecture, logging requirements, performance
requirements, remoting protocol, and how you can identify your remoting
server. You will need to build a prototype to find the appropriate


> - 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

View raw message