You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Salou Loic <lo...@gva.eri.ch> on 2003/02/27 12:04:40 UTC

Newbie question

Does anyone knows how I can specify dynamically the name of the file ? I
sort of would like the following
- Let Log4j use a property in my config file, likely
"log4j.appender.XXX.filePath=T:\\LOG"
- specify dynamically in my java classes wich filename to use. The reason is
that I am currently developping an application logging messages in files
situated in a shared folder, and I need to give a unique name for each file
(currently I chose to get the client machine name, which is unique)

I can (it already works) subclass RollingFileAppender (or others) and change
the setFile methods, but I would prefer a lot not to override Log4j
behaviors to avoid future diffulties in evoluating with Log4j.

But in the existing parameters I couldn't find anything but the
"log4j.appender.XXX.File=T:\\LOG\\LOGFILE.LOG"...

Please help me !
Thanks


Mr Lo�c Salou,
eRI Bancaire SA, 4-6 avenue industrielle, 1227 Carouge,
GVA NT-Architecture
 
' +41 22 309 10 46 (int 9246)
@  losalou@gva.eri.ch



**********************************************************************
 This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************



Re: Newbie question

Posted by donald larmee <dl...@utopiansoft.com>.
Not sure I have understood your problem exactly, but you could use 
environment substitution in your properties/xml file.

log4j.appender.XXX.filePath=T:\\LOG\${client_machine}.log


${client.machine} would need to have been set in the system properties 
before hand.





At 12:04 PM 2/27/2003 +0100, Salou Loic wrote:

>Does anyone knows how I can specify dynamically the name of the file ? I
>sort of would like the following
>- Let Log4j use a property in my config file, likely
>"log4j.appender.XXX.filePath=T:\\LOG"
>- specify dynamically in my java classes wich filename to use. The reason is
>that I am currently developping an application logging messages in files
>situated in a shared folder, and I need to give a unique name for each file
>(currently I chose to get the client machine name, which is unique)
>
>I can (it already works) subclass RollingFileAppender (or others) and change
>the setFile methods, but I would prefer a lot not to override Log4j
>behaviors to avoid future diffulties in evoluating with Log4j.
>
>But in the existing parameters I couldn't find anything but the
>"log4j.appender.XXX.File=T:\\LOG\\LOGFILE.LOG"...
>
>Please help me !
>Thanks
>
>
>Mr Loïc Salou,
>eRI Bancaire SA, 4-6 avenue industrielle, 1227 Carouge,
>GVA NT-Architecture
>
>' +41 22 309 10 46 (int 9246)
>@  losalou@gva.eri.ch
>
>
>
>**********************************************************************
>  This email and any files transmitted with it are confidential and
>intended solely for the use of the individual or entity to whom they
>are addressed. If you have received this email in error please notify
>the system manager.
>**********************************************************************
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-dev-help@jakarta.apache.org


+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
   donald h. larmee                               dlarmee@utopiansoft.com
                                                                          804.301.UTOP
                          utopian software concepts, inc.
                                  www.utopiansoft.com
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org