• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

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

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Lin,

You can get different log file by adding this below line to your file

log4j.appender.MYLOG=org.apache.log4j.DailyRollingFileAppender

This will create a new text file at the end of day. then u will get a seperate file for each day.


To test this, run your java program by changing dates.

Hope this helps you.

All the Best.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic