logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <go...@roseen.se>
Subject Re: setting RollingFileAppender output file name based on appdomain in ASP.NET application
Date Wed, 08 Feb 2006 10:55:39 GMT

Since there is (currently) no way of having conditional settings in the config file, I would
say that you have to implement the condition in code.

A clean way would be to use a custom property, e.g. 'FriendlyAppDomain' and set it at startup,
to either of the current appdomain or a predefined constant, depending on how the appdomain
looks. Then use this property when you configure the file name.

This would still make your application fairly flexible when it comes to configuring the file
name. In the future you can still change the filename anyway you want without recompiling.

But my personal opinion (yeah, you didn't ask for it, but here it is anyway...) is that the
cleanest solution (today) would be a different config for the asp.net process.

Why? Imagine that someone else who know log4net has to make some changes to you app. He will
probably have to go "source diving" in order to figure out the mechanics behind the file naming
scheme. Two config files will be less elegant, but completely straightforward for him/her
to understand.

In the future, you might be able to have two appenders with different configuration, that
both inherit all the common properties from a 'virtual' appender. Or something like that,
it has been discussed.

Sincerely,

Göran

----- Original Message -----
From: Log4Net
To: log4net-user@logging.apache.org
Sent: Tue, 7 Feb 2006 14:51:07 -0600
Subject: setting RollingFileAppender output file name based on appdomain in ASP.NET application

hi,
I have several services and an ASP.NET application installed on the same machine.
I want to use the rolling file appender and have each process log into its own set of files.

ideally i would like to use one log4net configuration file to configure logging for all the
running processes.
I figured out how to use the [%appdomain] to separate the output of the services to different
files: 
&lt;file type="log4net.Util.PatternString" value="C:\Logs\Log[%appdomain].txt" /&gt;

but since the ASP.NET application has as "unfriendly" application domain which looks something
like : "/LM/W3SVC/1/Root/MyW/MyWebApp-2-127838163201845375" 
log4net created a sub directory and puts the log file there.
is there any way to configure log4net to give a hard coded specific file name in case the
of a file name patterns that matches an IIS app domain?
is there any way to change the the ASP.NET code or deployment of the application in order
to force a certain friendly name instead of /LM/W3... ? 

Thanks,
Yuval



Mime
  • Unnamed multipart/mixed (inline, None, 0 bytes)
View raw message