You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Log4Net <lo...@gmail.com> on 2006/02/07 21:51:07 UTC
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:
<file type="log4net.Util.PatternString" value="C:\Logs\Log[%appdomain].txt"
/>
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
Re: setting RollingFileAppender output file name based on appdomain in ASP.NET application
Posted by Log4Net <lo...@gmail.com>.
thank you guys for the replies.
Georg - i did try your sample code + a little tweaks of my own and it does
get the job don
but the more i taught about Göran & piers responses it does make more sense
to keep the solution as simple as possible (especially for the guy
maintaining this code after I'm long gone :-) ).
Yuval
On 2/8/06, Piers Williams <pi...@gmail.com> wrote:
>
>
> On 08/02/06, Log4Net <lo...@gmail.com> wrote:
> >
> > hi,
> > I have several services and an ASP.NET<https://syds01.unisys.com/,DanaInfo=ASP.NET+?DanaTimeoutCtx=120000>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.
> >
> It's not what you're after, but I gave up attempting this and just used
> the processID for the ASP.Net apps, essentially hard-coding the 'friendly
> name' of my web app:
>
> <file type="log4net.Util.PatternString" value="C:\temp\MyApp_[%processid].log" />
>
> Perhaps you could get away with just having two log4net config's, one for
> all the services (using AppDomain friendly name), and one for the web app?
>
> The alternative I toyed with was that since PatternString accepts
> %property, I could just set a 'friendly name' global property in all my apps
> (use AppDomain name for .exe's, vdir name for web apps), and use that
> instead. But that sounded like work...
> --
> piers
> more pedantry at http://piers7.blogspot.com/
>
Re: setting RollingFileAppender output file name based on appdomain in ASP.NET application
Posted by Piers Williams <pi...@gmail.com>.
On 08/02/06, Log4Net <lo...@gmail.com> wrote:
>
> hi,
> I have several services and an ASP.NET<https://syds01.unisys.com/,DanaInfo=ASP.NET+?DanaTimeoutCtx=120000>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.
>
It's not what you're after, but I gave up attempting this and just used the
processID for the ASP.Net apps, essentially hard-coding the 'friendly name'
of my web app:
<file type="log4net.Util.PatternString"
value="C:\temp\MyApp_[%processid].log" />
Perhaps you could get away with just having two log4net config's, one for
all the services (using AppDomain friendly name), and one for the web app?
The alternative I toyed with was that since PatternString accepts %property,
I could just set a 'friendly name' global property in all my apps (use
AppDomain name for .exe's, vdir name for web apps), and use that instead.
But that sounded like work...
--
piers
more pedantry at http://piers7.blogspot.com/
RE: setting RollingFileAppender output file name based on appdomain in ASP.NET application
Posted by Georg Jansen <Ge...@FaktNet.com>.
Yuval,
Will programmatically changing the log file name (and keeping the rest of
the configuration from the config file) be sufficient?
If it is, I have a blog entry about it on:
http://www.l4ndash.com/Blogs/tabid/65/EntryID/18/Default.aspx
Best regards
Georg
Log4Net <http://www.l4ndash.com/> Dashboard / Log4Net Viewer
_____
From: Log4Net [mailto:log4net@gmail.com]
Sent: 7. februar 2006 21:51
To: log4net-user@logging.apache.org
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:
<file type="log4net.Util.PatternString" value="C:\Logs\Log[%appdomain].txt"
/>
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