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 parkirat <pa...@bsb.in> on 2014/08/03 12:55:10 UTC

Issue in RollingFileAppender when using both OnStartupTriggeringPolicy and TimeBasedTriggeringPolicy.

I am using Rolling File Appender with the Log4j2 2.0 version jar.

Now when I use both OnStartupTriggeringPolicy and TimeBasedTriggeringPolicy
set with the interval 3 minutes and use the OnStartupTriggeringPolicy policy
to roll at the server restart.

Now if, my file pattern has only date pattern set (%d{yyyy-MM-dd-HH-mm}) and
not %i, and I restart the server more than 3-4 times, the policy rolls the
file to future time and when the TimeBasedTriggeringPolicy tries to roll the
file, possibility is that file is already present due to rollover by
restarting the server many times and that earlier log file gets overwritten.

This leads to loss of the logging thus I think OnStartupTriggeringPolicy
policy when does a rollover, should all the currentTimeMillis to the log
file name as well.

Could you please look into this issue?

Regards,
Parkirat Singh Bagga.



--
View this message in context: http://apache-logging.6191.n7.nabble.com/Issue-in-RollingFileAppender-when-using-both-OnStartupTriggeringPolicy-and-TimeBasedTriggeringPolicy-tp49998.html
Sent from the Log4j - Users mailing list archive at Nabble.com.

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


Re: Issue in RollingFileAppender when using both OnStartupTriggeringPolicy and TimeBasedTriggeringPolicy.

Posted by Remko Popma <re...@gmail.com>.
Great, thanks!

Sent from my iPhone

> On 2014/08/03, at 22:08, Parkirat Bagga <pa...@bsb.in> wrote:
> 
> Thanks Remko for the reply.
> 
> I have raised the JIRA for the issue:
> https://issues.apache.org/jira/browse/LOG4J2-758
> 
> Regards,
> Parkirat Singh Bagga.
> 
> 
>> On Sun, Aug 3, 2014 at 6:20 PM, Remko Popma <re...@gmail.com> wrote:
>> 
>> It is probably better if you raise the issue on Jira yourself. (Anyone can
>> create a Jira account.) That way you'll get emails when there is an update
>> on your issue.
>> 
>> Thanks for pointing at the doc issue. I'll check it out when I have a
>> chance.
>> 
>> Remko
>> 
>> Sent from my iPhone
>> 
>>> On 2014/08/03, at 21:08, parkirat <pa...@bsb.in> wrote:
>>> 
>>> log4j2.xml <
>> http://apache-logging.6191.n7.nabble.com/file/n50001/log4j2.xml>
>>> 
>>> Thanks for the Reply Remko.
>>> 
>>> I have attached my config file in the post. I dont have the access to
>> JIRA
>>> so could not raise a bug though. Could you please do it for me?
>>> 
>>> As a workaround, I have added the %i to the file pattern, which solves
>> the
>>> problem of log overwriting.
>>> 
>>> Also found 1 more bug in documentation on webpage
>>> http://logging.apache.org/log4j/2.x/manual/appenders.html under
>>> TimeBasedTriggeringPolicy.
>>> 
>>> Here modulate if true and interval as 4 when current time is 3 should
>> make
>>> file starting at 4 and then 8, but the true behaviour is, it creates the
>>> file at 3 and then at 7 when modulate is set to true.
>>> 
>>> Regards,
>>> Parkirat Singh Bagga.
>>> 
>>> 
>>> 
>>> --
>>> View this message in context:
>> http://apache-logging.6191.n7.nabble.com/Issue-in-RollingFileAppender-when-using-both-OnStartupTriggeringPolicy-and-TimeBasedTriggeringPolicy-tp49998p50001.html
>>> Sent from the Log4j - Users mailing list archive at Nabble.com.
>>> 
>>> ---------------------------------------------------------------------
>>> 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: Issue in RollingFileAppender when using both OnStartupTriggeringPolicy and TimeBasedTriggeringPolicy.

Posted by Parkirat Bagga <pa...@bsb.in>.
Thanks Remko for the reply.

I have raised the JIRA for the issue:
https://issues.apache.org/jira/browse/LOG4J2-758

Regards,
Parkirat Singh Bagga.


On Sun, Aug 3, 2014 at 6:20 PM, Remko Popma <re...@gmail.com> wrote:

> It is probably better if you raise the issue on Jira yourself. (Anyone can
> create a Jira account.) That way you'll get emails when there is an update
> on your issue.
>
> Thanks for pointing at the doc issue. I'll check it out when I have a
> chance.
>
> Remko
>
> Sent from my iPhone
>
> > On 2014/08/03, at 21:08, parkirat <pa...@bsb.in> wrote:
> >
> > log4j2.xml <
> http://apache-logging.6191.n7.nabble.com/file/n50001/log4j2.xml>
> >
> > Thanks for the Reply Remko.
> >
> > I have attached my config file in the post. I dont have the access to
> JIRA
> > so could not raise a bug though. Could you please do it for me?
> >
> > As a workaround, I have added the %i to the file pattern, which solves
> the
> > problem of log overwriting.
> >
> > Also found 1 more bug in documentation on webpage
> > http://logging.apache.org/log4j/2.x/manual/appenders.html under
> > TimeBasedTriggeringPolicy.
> >
> > Here modulate if true and interval as 4 when current time is 3 should
> make
> > file starting at 4 and then 8, but the true behaviour is, it creates the
> > file at 3 and then at 7 when modulate is set to true.
> >
> > Regards,
> > Parkirat Singh Bagga.
> >
> >
> >
> > --
> > View this message in context:
> http://apache-logging.6191.n7.nabble.com/Issue-in-RollingFileAppender-when-using-both-OnStartupTriggeringPolicy-and-TimeBasedTriggeringPolicy-tp49998p50001.html
> > Sent from the Log4j - Users mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > 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: Issue in RollingFileAppender when using both OnStartupTriggeringPolicy and TimeBasedTriggeringPolicy.

Posted by Remko Popma <re...@gmail.com>.
It is probably better if you raise the issue on Jira yourself. (Anyone can create a Jira account.) That way you'll get emails when there is an update on your issue. 

Thanks for pointing at the doc issue. I'll check it out when I have a chance. 

Remko

Sent from my iPhone

> On 2014/08/03, at 21:08, parkirat <pa...@bsb.in> wrote:
> 
> log4j2.xml <http://apache-logging.6191.n7.nabble.com/file/n50001/log4j2.xml>  
> 
> Thanks for the Reply Remko.
> 
> I have attached my config file in the post. I dont have the access to JIRA
> so could not raise a bug though. Could you please do it for me?
> 
> As a workaround, I have added the %i to the file pattern, which solves the
> problem of log overwriting.
> 
> Also found 1 more bug in documentation on webpage
> http://logging.apache.org/log4j/2.x/manual/appenders.html under
> TimeBasedTriggeringPolicy.
> 
> Here modulate if true and interval as 4 when current time is 3 should make
> file starting at 4 and then 8, but the true behaviour is, it creates the
> file at 3 and then at 7 when modulate is set to true.
> 
> Regards,
> Parkirat Singh Bagga.
> 
> 
> 
> --
> View this message in context: http://apache-logging.6191.n7.nabble.com/Issue-in-RollingFileAppender-when-using-both-OnStartupTriggeringPolicy-and-TimeBasedTriggeringPolicy-tp49998p50001.html
> Sent from the Log4j - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> 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: Issue in RollingFileAppender when using both OnStartupTriggeringPolicy and TimeBasedTriggeringPolicy.

Posted by parkirat <pa...@bsb.in>.
log4j2.xml <http://apache-logging.6191.n7.nabble.com/file/n50001/log4j2.xml>  

Thanks for the Reply Remko.

I have attached my config file in the post. I dont have the access to JIRA
so could not raise a bug though. Could you please do it for me?

As a workaround, I have added the %i to the file pattern, which solves the
problem of log overwriting.

Also found 1 more bug in documentation on webpage
http://logging.apache.org/log4j/2.x/manual/appenders.html under
TimeBasedTriggeringPolicy.

Here modulate if true and interval as 4 when current time is 3 should make
file starting at 4 and then 8, but the true behaviour is, it creates the
file at 3 and then at 7 when modulate is set to true.

Regards,
Parkirat Singh Bagga.



--
View this message in context: http://apache-logging.6191.n7.nabble.com/Issue-in-RollingFileAppender-when-using-both-OnStartupTriggeringPolicy-and-TimeBasedTriggeringPolicy-tp49998p50001.html
Sent from the Log4j - Users mailing list archive at Nabble.com.

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


Re: Issue in RollingFileAppender when using both OnStartupTriggeringPolicy and TimeBasedTriggeringPolicy.

Posted by Remko Popma <re...@gmail.com>.
We will look into this, but can you create a Jira ticket for this and attach your config file?

One workaround may be to set append="true" for the rolling file appender. 

Remko

Sent from my iPhone

> On 2014/08/03, at 19:55, parkirat <pa...@bsb.in> wrote:
> 
> I am using Rolling File Appender with the Log4j2 2.0 version jar.
> 
> Now when I use both OnStartupTriggeringPolicy and TimeBasedTriggeringPolicy
> set with the interval 3 minutes and use the OnStartupTriggeringPolicy policy
> to roll at the server restart.
> 
> Now if, my file pattern has only date pattern set (%d{yyyy-MM-dd-HH-mm}) and
> not %i, and I restart the server more than 3-4 times, the policy rolls the
> file to future time and when the TimeBasedTriggeringPolicy tries to roll the
> file, possibility is that file is already present due to rollover by
> restarting the server many times and that earlier log file gets overwritten.
> 
> This leads to loss of the logging thus I think OnStartupTriggeringPolicy
> policy when does a rollover, should all the currentTimeMillis to the log
> file name as well.
> 
> Could you please look into this issue?
> 
> Regards,
> Parkirat Singh Bagga.
> 
> 
> 
> --
> View this message in context: http://apache-logging.6191.n7.nabble.com/Issue-in-RollingFileAppender-when-using-both-OnStartupTriggeringPolicy-and-TimeBasedTriggeringPolicy-tp49998.html
> Sent from the Log4j - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> 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