[logback-user] RollingFileAppender

Ceki Gulcu listid at qos.ch
Wed Oct 29 10:07:51 CET 2008


Hello Greg,

Please see

http://logback.qos.ch/xref-test/ch/qos/logback/core/rolling/TimeBasedRollingTest.html

for an example. You just need to replace

  RollingFileAppender<Object> rfa = new RollingFileAppender<Object>();

with

  RollingFileAppender<LoggingEvent> rfa =
                            new RollingFileAppender<LoggingEvent>();

and the layout variable should be of type PattenLayout (assuming that's the 
layout type you wish to use).

HTH,

Greg Flex wrote:
> Hi All,
> Could someone please post a simple example on how to use the 
> RollingFileAppender programmatically?
> I'm having problems figuring this out. (and massages such as: No context 
> given.... etc.)
> Basically what I'd like to do is set everything in my java program.
> Write to a file but adding stuff like computer's IP address and its name 
> etc.
> Most importantly, I'd like to modify the file name itself. Say in the 
> format: IP_address_date {yyyy-MM-dd_HH-mm-ss}.log
> Thanks a lot,
> Greg.
> 
>  
>  
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://qos.ch/mailman/listinfo/logback-user

-- 
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch


More information about the Logback-user mailing list