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 Andreas Mucha <si...@gmx.net> on 2010/08/31 11:56:59 UTC

configuration with dynamic settings

hello all

i try to configure log4net like log4j with some dynamic settings.
e.g. in log4j i can configure a dynamic file name like
log4j.appender.fileout.File=../some/path/${applicationname}_${somepropvalue}.log

for application name 'a' and somepropvalue 'p' this would result
in a file named a_p.log.
(this works also for rolling file appenders)

the only way i found until now is todo it in the application code.

big question is how to configure this behaviour in config file ??

many thanks in advance. 
-- 
Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!  
Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail

Re: configuration with dynamic settings

Posted by Matt Emory <re...@gmail.com>.
In your config file you can set your appender to be like:

<appender name="something" type="log4net.Appender.RollingFileAppender">
   <file type="log4net.Util.PatternString" value="%property{LogName}" />
    ...
</appender>

Then you just need to set the value of the property "LogName" somewhere,
which you can easily set it through command line arguments if you choose:
log4net.GlobalContext.Properties["LogName"] = @"c:\somewhere\file.log";

On Tue, Aug 31, 2010 at 6:01 AM, Andreas Mucha <si...@gmx.net> wrote:

> i forgot to say that in my little log4j example
>
> "log4j.appender.fileout.File=../some/path/${applicationname}_${somepropvalue}.log"
> the applicationname and somepropvalue was defined as
> vm prop (java -Dsomepropvalue=...)
>
> i would like to set up the same for log4net .
>
> -------- Original-Nachricht --------
> > Datum: Tue, 31 Aug 2010 11:56:59 +0200
> > Von: "Andreas Mucha" <si...@gmx.net>
> > An: log4net-user@logging.apache.org
> > Betreff: configuration with dynamic settings
>
> > hello all
> >
> > i try to configure log4net like log4j with some dynamic settings.
> > e.g. in log4j i can configure a dynamic file name like
> >
> log4j.appender.fileout.File=../some/path/${applicationname}_${somepropvalue}.log
> >
> > for application name 'a' and somepropvalue 'p' this would result
> > in a file named a_p.log.
> > (this works also for rolling file appenders)
> >
> > the only way i found until now is todo it in the application code.
> >
> > big question is how to configure this behaviour in config file ??
> >
> > many thanks in advance.
> > --
> > Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!
> > Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail
>
> --
> GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
>

Re: configuration with dynamic settings

Posted by Andreas Mucha <si...@gmx.net>.
i forgot to say that in my little log4j example
"log4j.appender.fileout.File=../some/path/${applicationname}_${somepropvalue}.log"
the applicationname and somepropvalue was defined as
vm prop (java -Dsomepropvalue=...)

i would like to set up the same for log4net .

-------- Original-Nachricht --------
> Datum: Tue, 31 Aug 2010 11:56:59 +0200
> Von: "Andreas Mucha" <si...@gmx.net>
> An: log4net-user@logging.apache.org
> Betreff: configuration with dynamic settings

> hello all
> 
> i try to configure log4net like log4j with some dynamic settings.
> e.g. in log4j i can configure a dynamic file name like
> log4j.appender.fileout.File=../some/path/${applicationname}_${somepropvalue}.log
> 
> for application name 'a' and somepropvalue 'p' this would result
> in a file named a_p.log.
> (this works also for rolling file appenders)
> 
> the only way i found until now is todo it in the application code.
> 
> big question is how to configure this behaviour in config file ??
> 
> many thanks in advance. 
> -- 
> Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!  
> Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail

-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01