This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Other Open Source Projects and the fly likes How to use log4j to log a file whose file name is daily based? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "How to use log4j to log a file whose file name is daily based? " Watch "How to use log4j to log a file whose file name is daily based? " New topic
Author

How to use log4j to log a file whose file name is daily based?

Hai Lin
Ranch Hand

Joined: May 23, 2004
Posts: 79
Hi All,
I'm using log4j to do log for the java application, and the logged file name should be automatically changed every day, for example, today's log file should be 12152004test1.log (today is Dec/15), and tomorrow's log will automatically become 12162004test1.log when I start up the application.
Could anyone tell me how to set the property about:

log4j.rootCategory=DEBUG, MYLOG
log4j.appender.MYLOG.File=C:\\tomcat\\webapps\\test\\...

Thanks a lot.

Hai
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

This is not a Servlet question, moving to Other Open Source Projects
[ December 16, 2004: Message edited by: David O'Meara ]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Take a look at the javadocs of org.apache.log4j.DailyRollingFileAppender.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to use log4j to log a file whose file name is daily based?
 
It's not a secret anymore!