I was just looking at the code and I'm not sure you are aware that the 
RollingFileAppender uses a RolloverStrategy.  You don't have to configure it as 
DefaultRolloverStrategy is used if you don't specify one.  The rollover 
strategy has  method named rollover that is passed the RollingFileManager.  
This method takes care of actually performing the renaming of files, etc.  You 
can already extend this class and override that method to perform work before 
or after doing super.rollover(fileManager).  

Would this fulfill your need?  

Ralph




On Aug 29, 2012, at 2:35 PM, Ralph Goers wrote:

> Thanks for downloading Log4j 2 and working with it!
> 
> RollingFileAppender currently doesn't support a listener but I see no reason 
> it couldn't.  Feel free to create a Jira issue for this feature.  If you 
> would like to implement it as well that would be fantastic!
> 
> Ralph
> 
> On Aug 29, 2012, at 2:26 PM, Tushar Kapila wrote:
> 
>> Happy to have downloaded the alpha sources using wget (wget is nifty worked
>> on windows too : wget -e robots=off --cut-dirs=3 -r -p -np
>> --no-check-certificate
>> https://repository.apache.org/content/repositories/orgapachelogging-009/org/apache/logging/log4j/)
>> and making my first test project with log4j2 !
>> 
>> Upgraded the conf to write to a rolling file.
>> 
>> *Ralph : *Where can we learn about using the rolling file manager? can a
>> class subscribe to roll events so we can do custom tasks for old files
>> (like pack them up in to a password protected zip and store in an alternate
>> location, when the number of files is more than 300 ? The listener would
>> count the number of files etc but the log4j rolling manager should take
>> care of 'missing files' as we would delete them after archiving). if it
>> does not have support for this could you add it?
>> 
>> The conf I used :
>> 
>> <?xml version="1.0" encoding="UTF-8"?>
>> <configuration status="debug">
>> <appenders>
>>   <Console name="Console" target="SYSTEM_OUT">
>>     <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} -
>> %msg%n"/>
>>   </Console>
>> 
>>   <RollingFile name="Rolling-1" fileName="logs/a.log"
>>                          filePattern="logs/test1-${sd:type}.%i.log.gz">
>>               <PatternLayout>
>>                 <pattern>%d %p %C [%t] %m%n</pattern> <!-- %d %p %C{1.}
>> [%t] %m%n -->
>>               </PatternLayout>
>>               <SizeBasedTriggeringPolicy size="500" />
>> <!-- want to hook a class here to listen to rolling events after they occur
>> -->
>>    </RollingFile>
>> 
>> </appenders>
>> <loggers>
>>   <root level="debug">
>>     <appender-ref ref="Console"/>
>>     <appender-ref ref="Rolling-1"/>
>>   </root>
>> </loggers>
>> </configuration>
>> 
>> *Users : *For anyone interested - here is the source of the eclipse project
>> http://sel2in.com/pages/log4j/ , with config xml and java files. All it
>> needs are the log4j jars that you can get from
>> http://logging.apache.org/log4j/2.x/ if the site does not open try after an
>> hour ... :) might be down for temporary maintenance.
>> 
>> Regards
>> Tushar Kapila
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org

Reply via email to