File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Open Source Projects and the fly likes generate dynamic log file in apache log4j Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "generate dynamic log file in apache log4j" Watch "generate dynamic log file in apache log4j" New topic
Author

generate dynamic log file in apache log4j

YuenLian Wu
Ranch Hand

Joined: Nov 16, 2005
Posts: 73
Dear all,

I am currently using log4j as my logging system. I am curious if log4j can generate dynamic log file. As you know log4j.properties can allow users to set up various of setting. Stupid me tried to imagine the following can be valid:

log4j.appender.myApp.File=c:/%d{ISO8601}.log

Unfortunately, that just act like static log file. I just want to know is there any dynamic way to generate dynamic logger? Such as 20060313085033.log, or 20060313185533 ? Can I do it by configure the properties file ?

Thanks in advance

Transistor
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39535
    
  27
Moving this tread to "Other Open Source Projects", where log4j is discussed.


Ping & DNS - updated with new look and Ping home screen widget
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18113
    
    8

Aren't you just describing DailyRollingFileAppender?
YuenLian Wu
Ranch Hand

Joined: Nov 16, 2005
Posts: 73
Not really, the dailyrolling thing is just to add the time stamp to your preset log file name, it's not dynamic at all. I want wholely dynamic, like wholely wheat !!!
[ March 15, 2006: Message edited by: YuenLian Wu ]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18113
    
    8

So, did you test DailyRollingFileAppender with something like this?
Ovidiu Guse
Greenhorn

Joined: Oct 12, 2008
Posts: 7
I was also interested in this. In case someone is still looking for a solution, have a look here:
http://cognitivecache.blogspot.com/2008/08/log4j-writing-to-dynamic-log-file-for.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: generate dynamic log file in apache log4j
 
Similar Threads
Append to beginning of file (log4j)
Getting tha name of the JSP page?
LOG4j how to relase the file, or drain contents
persist previous server.log after server restarts using log4j.xml
Log issue of Tomcat 6.0.26