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 Akash Jain <ak...@gmail.com> on 2014/06/03 08:54:15 UTC

DailyRollingFileAppender with Max size

Hi,

I am using org.apache.log4j.DailyRollingFileAppender for my logs with
following conversion pattern :

But I also want to use max File Size with this, so that the file is rolled
if it reaches a max size even if same day.

How can I achieve this ?

Thanks.

Re: DailyRollingFileAppender with Max size

Posted by Akash Jain <ak...@gmail.com>.
This is my current appender -

<appender name="rolling.log"
class="org.apache.log4j.DailyRollingFileAppender">
        <param name="file"  value="mylog.log" />
        <param name="append" value="true" />
        <param name="bufferedIO" value="false" />

        <param name="DatePattern" value="'.'yyyy-MM-dd" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{yyyy-MM-dd
HH:mm:ss,SSS} %-5p [%-10t%x] %-10.10c{1} %m%n" />
        </layout>
    </appender>


On Tue, Jun 3, 2014 at 5:17 AM, James Hutton <ja...@gmail.com>
wrote:

> Akash,
> You can, but I think without modifying the conversion pattern (adding %i)
> it isn't possible.  You can use multiple rollover policies, you would end
> up using the SizeBaseRolloverPolicy(?).  I'm assuming if you have the time
> based rollover policy that you're using the date string.
>
> James
>
>
> On Tue, Jun 3, 2014 at 7:21 AM, Steffen Ryll <st...@iteratec.de>
> wrote:
>
> > Looks as if you forgot pasting the conversion pattern.
> > Can you clarify?
> >
> > /Steffen
> >
> > Am 03.06.2014 08:54, schrieb Akash Jain:
> > > Hi,
> > >
> > > I am using org.apache.log4j.DailyRollingFileAppender for my logs with
> > > following conversion pattern :
> > >
> > > But I also want to use max File Size with this, so that the file is
> > rolled
> > > if it reaches a max size even if same day.
> > >
> > > How can I achieve this ?
> > >
> > > Thanks.
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
> >
>

Re: DailyRollingFileAppender with Max size

Posted by James Hutton <ja...@gmail.com>.
Akash,
You can, but I think without modifying the conversion pattern (adding %i)
it isn't possible.  You can use multiple rollover policies, you would end
up using the SizeBaseRolloverPolicy(?).  I'm assuming if you have the time
based rollover policy that you're using the date string.

James


On Tue, Jun 3, 2014 at 7:21 AM, Steffen Ryll <st...@iteratec.de>
wrote:

> Looks as if you forgot pasting the conversion pattern.
> Can you clarify?
>
> /Steffen
>
> Am 03.06.2014 08:54, schrieb Akash Jain:
> > Hi,
> >
> > I am using org.apache.log4j.DailyRollingFileAppender for my logs with
> > following conversion pattern :
> >
> > But I also want to use max File Size with this, so that the file is
> rolled
> > if it reaches a max size even if same day.
> >
> > How can I achieve this ?
> >
> > Thanks.
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

Re: DailyRollingFileAppender with Max size

Posted by Steffen Ryll <st...@iteratec.de>.
Looks as if you forgot pasting the conversion pattern.
Can you clarify?

/Steffen

Am 03.06.2014 08:54, schrieb Akash Jain:
> Hi,
> 
> I am using org.apache.log4j.DailyRollingFileAppender for my logs with
> following conversion pattern :
> 
> But I also want to use max File Size with this, so that the file is rolled
> if it reaches a max size even if same day.
> 
> How can I achieve this ?
> 
> Thanks.
> 


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