I am fairly new to LOG4J, but you can set up a Properties object in your
application and use that to initialize the LOG4J engine.  Here is a small
snippet of code to get you started.  So with this method, you can use any
logic you need to specify the filename.


String myTempFirDir = "..."; //logic to build custom directory path
Properties props = new Properties();
props.setProperty("log4j.appender.R","org.apache.log4j.RollingFileAppender");
props.setProperty("log4j.appender.R.MaxFileSize","1000KB");
...
props.setProperty("log4j.appender.R.File",myTempFileDir + File.separator +
"myfilename.log");
props.setProperty("log4j.appender.R.layout","org.apache.log4j.SimpleLayout");
//then use static method in log4j to initialize
PropertyConfigurator.configure(props);





Luca Ferrari wrote:
> 
> Hi,
> having the following configuration in my log4j.xml file:
> 
> 
>               
>               
>               
>               
>               
>       
> 
> is it possible to specify the log directory where should be created? In
> other 
> words, is it possible to specify the root directory for logging, possibly
> from 
> the application itself (not in the configuration file)?
> 
> Thanks,
> Luca
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/specify-the-relative-directory-to-log-tp23387448p23393065.html
Sent from the Log4j - Users mailing list archive at Nabble.com.

Reply via email to