This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Other Open Source Projects and the fly likes Adding Date & time Stamp in Log file name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Adding Date & time Stamp in Log file name" Watch "Adding Date & time Stamp in Log file name" New topic
Author

Adding Date & time Stamp in Log file name

Yugandhar Ghanta
Greenhorn

Joined: Jan 12, 2009
Posts: 6
Hi,
I am using Log4j. In configuration file(XML File), i am using RollingFileAppender... i am generationg output log file(AppINFO.log) based on maxFileSize property. Can i include or append Date pattern in output log file name dynamically.



In the above XML code...need to append Date pattern in file name, i.e:
<param name="File" value="C:/temp/AppINFO.<Year&Date>.log"/>
Can anyone please help me on this?
Thanks in advance,
Yugandhar.
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
You will probably need to use a custom appender.

I have not tried this out, but there is a code snippet and example configuration of a "Timestamp File Appender" on the log4j wiki's Useful Code section. It looks pretty old, so may need updating to use with a newer version of log4j.

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Adding Date & time Stamp in Log file name
 
Similar Threads
what is wrong with log4j configration
Capture logs to file via log4j.xml
Avoid additional server.log debug lines
Jboss Console not updating
How to monitor log file in jboss for sending mails,when error or excetion found in log