1

I want to create a log file after every 4 hours, currently I am, using below configuration:

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n

# configure the daily rolling file appender
log4j.appender.DAILY=org.apache.log4j.DailyRollingFileAppender
log4j.appender.DAILY.File=/apps/jmt/jmt.log
log4j.appender.DAILY.DatePattern='.'yyyy-MM-dd-HH-mm
log4j.appender.DAILY.layout=org.apache.log4j.PatternLayout
log4j.appender.DAILY.layout.ConversionPattern=%d %p [%c] - <%m>%n

Googled it but didn't see option to specify time (i.e. 4 hour)

nilFi
  • 197
  • 2
  • 18
  • 2
    Wonder why your google search did not give this possible dup: http://stackoverflow.com/questions/1711423/how-to-rotate-log-files-based-on-time-rather-than-size-in-log4j – ring bearer Jun 30 '15 at 05:48
  • 1
    Maybe he Googled "it" by mistake ^ ^ – Tim Biegeleisen Jun 30 '15 at 05:49
  • 1
    `org.apache.log4j.DailyRollingFileAppender` does not appear to support rolling over every 4 hours out of the box. – Tim Biegeleisen Jun 30 '15 at 05:53
  • 1
    yes, I did check that question but I didnt see the option to specify the time. I want log to be generated after every 4 hour not hourly, please help. – nilFi Jun 30 '15 at 05:54
  • 1
    possible duplicate of [How to configure a log4j file appender which rolls the log file every 15 minutes](http://stackoverflow.com/questions/4858022/how-to-configure-a-log4j-file-appender-which-rolls-the-log-file-every-15-minutes) – Tim Biegeleisen Jun 30 '15 at 05:55
  • @TimBiegeleisen agreed. Duplicate, and flagged. – Benjamin Marwell Aug 18 '15 at 10:16

0 Answers0