You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by ying lcs <yi...@gmail.com> on 2006/11/21 23:21:31 UTC

File Appender in log4j

Hi,

Can you please tell me how can I configure file appender so that it
writes to 1 log file per data and have the old one stays?

Thank you.

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


Re: File Appender in log4j

Posted by Curt Arnold <ca...@apache.org>.
On Nov 29, 2006, at 10:11 PM, ying lcs wrote:

> I try it, but I get this error "
>
> log4j:WARN No such property [maxBackupIndex] in
> org.apache.log4j.DailyRollingFileAppender.
>
> I put this line in the log4j properties file.
> log4j.appender.ACCESS.MaxBackupIndex=7
>
>
> On 11/28/06, Shuh Chang <sh...@gemalto.com> wrote:
>> I think you can set the MaxBackupIndex parameter like this:
>>
>> log4j.appender.drfa.MaxBackupIndex=7

That parameter only exists for RollingFileAppender.  To the best of  
my knowledge there isn't a way to do that in log4j, but since the  
files should be closed, you are free to have a cron job to do that  
maintenance.



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


Re: File Appender in log4j

Posted by ying lcs <yi...@gmail.com>.
I try it, but I get this error "

log4j:WARN No such property [maxBackupIndex] in
org.apache.log4j.DailyRollingFileAppender.

I put this line in the log4j properties file.
log4j.appender.ACCESS.MaxBackupIndex=7


On 11/28/06, Shuh Chang <sh...@gemalto.com> wrote:
> I think you can set the MaxBackupIndex parameter like this:
>
> log4j.appender.drfa.MaxBackupIndex=7
>
>
> -----Original Message-----
> From: ying lcs [mailto:yinglcs@gmail.com]
> Sent: Monday, November 27, 2006 10:42 PM
> To: Log4J Users List
> Subject: Re: File Appender in log4j
>
>
> Thanks for the advice.
>
> Can you please tell me how can i only keep the last 7 days of the log ?
>
> Thank you.
>
>
> On 11/21/06, Curt Arnold <ca...@apache.org> wrote:
> >
> > On Nov 21, 2006, at 4:21 PM, ying lcs wrote:
> >
> > > Hi,
> > >
> > > Can you please tell me how can I configure file appender so that it
> > > writes to 1 log file per data and have the old one stays?
> > >
> > > Thank you.
> > >
> >
> > I guessing that you meant "1 log file per DAY".  If that is your
> > request, you could use a DailyRollingFileAppender which would write
> > all log messages to a file which would be renamed after the day
> > changes.   The configuration would looks something like:
> >
> >
> > log4j.rootLogger=DEBUG, drfa
> > log4j.appender.drfa=org.apache.log4j.DailyRollingFileAppender
> > log4j.appender.drfa.file=mylog.log
> > log4j.appender.drfa.Append=false
> > log4j.appender.drfa.layout=org.apache.log4j.PatternLayout
> > log4j.appender.drfa.layout.ConversionPattern=%m\n
> >
> > Messages would be logged to mylog.log and after the day changes the
> > file would be close, renamed mylog.log.2006-11-21 and subsequent
> > logging would be captured in a new mylog.log file.
> >
> > There has been some development of a MultiFileAppender that could
> > actually write the file in place and would not require renaming the
> > file, but that isn't working yet.
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

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


RE: File Appender in log4j

Posted by Shuh Chang <sh...@gemalto.com>.
I think you can set the MaxBackupIndex parameter like this:

log4j.appender.drfa.MaxBackupIndex=7


-----Original Message-----
From: ying lcs [mailto:yinglcs@gmail.com]
Sent: Monday, November 27, 2006 10:42 PM
To: Log4J Users List
Subject: Re: File Appender in log4j


Thanks for the advice.

Can you please tell me how can i only keep the last 7 days of the log ?

Thank you.


On 11/21/06, Curt Arnold <ca...@apache.org> wrote:
>
> On Nov 21, 2006, at 4:21 PM, ying lcs wrote:
>
> > Hi,
> >
> > Can you please tell me how can I configure file appender so that it
> > writes to 1 log file per data and have the old one stays?
> >
> > Thank you.
> >
>
> I guessing that you meant "1 log file per DAY".  If that is your
> request, you could use a DailyRollingFileAppender which would write
> all log messages to a file which would be renamed after the day
> changes.   The configuration would looks something like:
>
>
> log4j.rootLogger=DEBUG, drfa
> log4j.appender.drfa=org.apache.log4j.DailyRollingFileAppender
> log4j.appender.drfa.file=mylog.log
> log4j.appender.drfa.Append=false
> log4j.appender.drfa.layout=org.apache.log4j.PatternLayout
> log4j.appender.drfa.layout.ConversionPattern=%m\n
>
> Messages would be logged to mylog.log and after the day changes the
> file would be close, renamed mylog.log.2006-11-21 and subsequent
> logging would be captured in a new mylog.log file.
>
> There has been some development of a MultiFileAppender that could
> actually write the file in place and would not require renaming the
> file, but that isn't working yet.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

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


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


Re: File Appender in log4j

Posted by ying lcs <yi...@gmail.com>.
Thanks for the advice.

Can you please tell me how can i only keep the last 7 days of the log ?

Thank you.


On 11/21/06, Curt Arnold <ca...@apache.org> wrote:
>
> On Nov 21, 2006, at 4:21 PM, ying lcs wrote:
>
> > Hi,
> >
> > Can you please tell me how can I configure file appender so that it
> > writes to 1 log file per data and have the old one stays?
> >
> > Thank you.
> >
>
> I guessing that you meant "1 log file per DAY".  If that is your
> request, you could use a DailyRollingFileAppender which would write
> all log messages to a file which would be renamed after the day
> changes.   The configuration would looks something like:
>
>
> log4j.rootLogger=DEBUG, drfa
> log4j.appender.drfa=org.apache.log4j.DailyRollingFileAppender
> log4j.appender.drfa.file=mylog.log
> log4j.appender.drfa.Append=false
> log4j.appender.drfa.layout=org.apache.log4j.PatternLayout
> log4j.appender.drfa.layout.ConversionPattern=%m\n
>
> Messages would be logged to mylog.log and after the day changes the
> file would be close, renamed mylog.log.2006-11-21 and subsequent
> logging would be captured in a new mylog.log file.
>
> There has been some development of a MultiFileAppender that could
> actually write the file in place and would not require renaming the
> file, but that isn't working yet.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

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


Re: File Appender in log4j

Posted by Chris Dillon <c1...@gmail.com>.
Curt Arnold <carnold <at> apache.org> writes:

> On Nov 21, 2006, at 4:21 PM, ying lcs wrote:
> 
> > Hi,
> >
> > Can you please tell me how can I configure file appender so that it
> > writes to 1 log file per data and have the old one stays?
> >
> > Thank you.
> 
> I guessing that you meant "1 log file per DAY".  If that is your  
> request, you could use a DailyRollingFileAppender ...

Alternatively, if you're looking for one log file per application launch, you
could have a look at http://permalink.gmane.org/gmane.comp.jakarta.log4j.user/14467



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


Re: File Appender in log4j

Posted by Curt Arnold <ca...@apache.org>.
On Nov 21, 2006, at 4:21 PM, ying lcs wrote:

> Hi,
>
> Can you please tell me how can I configure file appender so that it
> writes to 1 log file per data and have the old one stays?
>
> Thank you.
>

I guessing that you meant "1 log file per DAY".  If that is your  
request, you could use a DailyRollingFileAppender which would write  
all log messages to a file which would be renamed after the day  
changes.   The configuration would looks something like:


log4j.rootLogger=DEBUG, drfa
log4j.appender.drfa=org.apache.log4j.DailyRollingFileAppender
log4j.appender.drfa.file=mylog.log
log4j.appender.drfa.Append=false
log4j.appender.drfa.layout=org.apache.log4j.PatternLayout
log4j.appender.drfa.layout.ConversionPattern=%m\n

Messages would be logged to mylog.log and after the day changes the  
file would be close, renamed mylog.log.2006-11-21 and subsequent  
logging would be captured in a new mylog.log file.

There has been some development of a MultiFileAppender that could  
actually write the file in place and would not require renaming the  
file, but that isn't working yet.



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