From: John O. <joh...@o-...> - 2007-02-15 20:05:43
|
It has this nifty feature built in, no need to write more code - see below.... Robert Jacobson wrote: > At 07:53 AM 2/15/2007, Dirk Vleugels wrote: > >> Hi, >> >> is there a easy way to give the rotated files a different suffix? >> Currently a rotated file will be named: >> >> example.log -> example.log.1 >> >> but i need something like: >> >> example.log.YYYYMMDDHH >> >> Maybe by defining a callback? I can't find anything in the docs ... >> > > Therefore, you need to subclass and override the log_message() method in order to get the name change you want. Do you know how to do that? I'm not an expert, but I've done something similar before with other modules. > From my log4perl.conf file: log4perl.logger.DataSite = DEBUG, DebugLog log4perl.appender.DebugLog = Log::Dispatch::FileRotate log4perl.appender.DebugLog.min_level=debug log4perl.appender.DebugLog.max=10 log4perl.appender.DebugLog.DatePattern=yyyy-MM-dd log4perl.appender.DebugLog.TZ=UTC log4perl.appender.DebugLog.filename=/tmp/debug_log log4perl.appender.DebugLog.mode=append log4perl.appender.DebugLog.layout=PatternLayout log4perl.appender.DebugLog.layout.ConversionPattern =[%d] [%P] %M(%p) - %m%n The bit you want is DatePattern - it sets the pattern for the rotated files - in your case: DatePattern=yyyyMMdd When the evaluated version of that changes, it will do the rename and start a new file. cheers John |