10x, thatâs realy helpful. I

-----Original Message-----
From: Ceki Gïlcï [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 25, 2004 11:01 AM
To: Log4J Users List
Subject: RE: smart file name

Yair,

Are you calling PropertiesConfigurator, DOMConfigrator, JoranConfigrator 
yourself? If you are, you can fill in the value of the variable before 
invoking the configurator.

To give you an idea, assume you use PropertiesConfigurator.


     Properties props = new Properties();
     FileInputStream istream = new 
FileInputStream("/your/config/file.properties");
     props.load(istream);
     istream.close()

     // set the value of "now" to a string formatted according to your
     // liking
     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-ss");
     props.setProperty("now", sdf.format(new Date());

     // now configure log4j
     new PropertiesConfigurator().doConfigure(props, 
LogManager.getLogggingRepository());


Your config file in properties format would look like

log4j.rootLogger=debug, KUKU
log4j.appender.KUKU=org.apache.log4j.FileAppender
log4j.appender.KUKU.File=/wombat/kuku-${now}.log
etc...

I'd like to note that the choice of using "kuku" as a file name was yours, 
certainly not mine. :-)

HTH,

At 06:43 AM 11/25/2004, Yair Ogen wrote:
>I've thiught about it, but when is try to put a variable on the file name 
>it is ignored. Please note I'm looking for a static decleration in my 
>config file that will get a dynamic value every time the file is created. 
>i.e. fileName="cat_{d}.log" or something like that.

-- 
Ceki GÃlcÃ

  The complete log4j manual:  http://qos.ch/eclm
  Professional log4j support: http://qos.ch/log4jSupport  



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to