• 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
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

log4j DailyRollingFileAppender not creating new files

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having difficulty properly configuring log4j on Tomcat to create log files as expected. I am using the 'create a file each minute' DatePattern for testing. I havent had much success with this particular feature although the rest of the configurations seem to work as advertised.

Sample of log4j.properties file:

### INTRANET/JOB_TRACKING APPENDER ##############################
log4j.category.com.famc.intranet.servlet.jobTracking = DEBUG, INTRANET_JOB_TRACKING
log4j.category.com.famc.intranet.jsp.jobTracking = DEBUG, INTRANET_JOB_TRACKING
log4j.category.com.famc.core.email = DEBUG, INTRANET_JOB_TRACKING

## DAILY ROLLING FILE APPENDER
log4j.appender.INTRANET_JOB_TRACKING=org.apache.log4j.DailyRollingFileAppender
log4j.appender.INTRANET_JOB_TRACKING.file = logs/intranet/JobTracking.log
##log4j.appender.INTRANET_JOB_TRACKING.threshold=INFO
log4j.appender.INTRANET_JOB_TRACKING.DatePattern = yyyy-MM-dd-HH-mm
log4j.appender.INTRANET_JOB_TRACKING.append = true
log4j.appender.INTRANET_JOB_TRACKING.layout=org.apache.log4j.PatternLayout
log4j.appender.INTRANET_JOB_TRACKING.layout.ConversionPattern=%-5p :%d{ISO8601} [%c{3}]- %m%n


Any response is appreciated.

Thanks,
robert
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Robert,

According to the book: "Logging in Java with the JDK 1.4 Logging API and Apache log4j", by Samudra Gupta, the line you have:
log4j.appender.INTRANET_JOB_TRACKING.DatePattern = yyyy-MM-dd-HH-mm

Should be:
log4j.appender.INTRANET_JOB_TRACKING.DatePattern = '.' yyyy-MM-dd-HH-mm

I don't see any explanation for the '.' in the value portion.
He does say the DatePattern follows the java.text.SimpleDataFormat object formatting style. But, I don't see the '.' mentioned anywhere in the spec.
http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html

Cheers,
Mike
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought the dot('.') was just a formatter, meaning if you have provided date pattern, then it would create a log file name with the specified name and date separated with a dot. like following,

Otherwise it would create a file with the specified name and date not separated with dot. like this,

Regards,
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My log4j.properites

 
If you live in a cold climate and on the grid, incandescent light can use less energy than LED. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic