Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

Change daily log rotation time

Avatar

Level 2

If logs are configured to rollover/rotate daily (pattern '.'yyyy-MM-dd), is it possible to set the time that they rollover?  For example, 11:55pm instead of midnight.

4 Replies

Avatar

Level 10

See this configuration, you can configure pattern here

http://localhost:4502/system/console/configMgr at Apache Sling Logging Configuration

Article which give more details on implmentation

http://www.wemblog.com/2012/06/how-to-rotate-logs-in-cq-wem.html

Avatar

Administrator

Hi

Please refer to the articles mentioned below :-

Link:- http://www.wemblog.com/2012/06/how-to-rotate-logs-in-cq-wem.html

Link:-http://sling.apache.org/documentation/development/logging.html#log-file-rotation

//

Scheduled Rotation

The rolling schedule is specified by setting the org.apache.sling.commons.log.file.size property to a java.text.SimpleDateFormat pattern. Literal text (such as a leading dot) to be included must be enclosed within a pair of single quotes. A formatted version of the date pattern is used as the suffix for the rolled file name. Internally the Log bundle configures a TimeBasedRollingPolicy for the appender. Refer to TimeBasedRollingPolicy for more details around the pattern format

For example, if the log file is configured as /foo/bar.log and the pattern set to '.'yyyy-MM-dd, on 2001-02-16 at midnight, the logging file /foo/bar.log will be renamed to /foo/bar.log.2001-02-16 and logging for 2001-02-17 will continue in a new /foo/bar.log file until it rolls over the next day.

It is possible to specify monthly, weekly, half-daily, daily, hourly, or minutely rollover schedules.

                                      
DatePatternRollover scheduleExample
'.'yyyy-MMRollover at the beginning of each monthAt midnight of May 31st, 2002 /foo/bar.log will be copied to /foo/bar.log.2002-05. Logging for the month of June will be output to /foo/bar.log until it is also rolled over the next month.
'.'yyyy-wwRollover at the first day of each week. The first day of the week depends on the locale.Assuming the first day of the week is Sunday, on Saturday midnight, June 9th 2002, the file /foo/bar.log will be copied to /foo/bar.log.2002-23. Logging for the 24th week of 2002 will be output to /foo/bar.log until it is rolled over the next week.
'.'yyyy-MM-ddRollover at midnight each day.At midnight, on March 8th, 2002, /foo/bar.log will be copied to /foo/bar.log.2002-03-08. Logging for the 9th day of March will be output to /foo/bar.log until it is rolled over the next day.
'.'yyyy-MM-dd-aRollover at midnight and midday of each day.at noon, on March 9th, 2002, /foo/bar.log will be copied to /foo/bar.log.2002-03-09-AM. Logging for the afternoon of the 9th will be output to /foo/bar.log until it is rolled over at midnight.
'.'yyyy-MM-dd-HHRollover at the top of every hour.At approximately 11:00.000 o'clock on March 9th, 2002, /foo/bar.log will be copied to /foo/bar.log.2002-03-09-10. Logging for the 11th hour of the 9th of March will be output to /foo/bar.log until it is rolled over at the beginning of the next hour.
'.'yyyy-MM-dd-HH-mmRollover at the beginning of every minute.At approximately 11:23,000, on March 9th, 2001, /foo/bar.log will be copied to /foo/bar.log.2001-03-09-10-22. Logging for the minute of 11:23 (9th of March) will be output to /foo/bar.log until it is rolled over the next minute.

I hope this would help you.

Thanks and Regards

Kautuk Sahni



Kautuk Sahni

Avatar

Level 10

Yes... Use this pattern to set the time aswell

yyyy-MM-dd-HH-mm

Avatar

Level 2

Sorry, I think I misstated my question.  I still want a daily log (one per day), but I want them to rollover not at midnight.  I want them to roll at say 11pm.  I understand that changing the pattern to something like yyyy-MM-dd-HH would roll them every hour but then I would end up with 24 logs per day.

The reason I ask is that we have a process that sweeps/copies logs to a central server.  That process has to run at 11:59pm.  It is not picking up the AEM logs for that day because they have not rolled yet.