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 "Hill, Alex" <Al...@dkib.com> on 2007/07/20 14:33:22 UTC

log4j Timezones

Hi,
 
I'm currently using log4j 1.2.14 and have been having some trouble
logging in GMT. Is there any way of setting the timezone of an appender?
I ended up doing this:
 
    TimeZone.setDefault(TimeZone.getTimeZone("GMT"));

This seems to work but it means my appender has to set this property
globally. This isn't ideal as it may cause unexpected results in any
applications using my appender.
 
I saw somewhere that ConversionPattern has been extended in version 1.3
to take a second parameter for a timezone such as below:
 
    log4j.appender.FILE.layout.conversionPattern   = %d{yyyy-MM-dd
hh:mm:ss z}{GMT+0} %-5p [%c{1}:%t] %m%n

Will this mean that the time based rolling appenders will roll correctly
at the end of day as specified by the time zone or is this purely for
the date text in the log? Is there a better way to specify the timezone
properly?
 
I extended the DailyRollingFileAppender to delete out of date files, as
it rolls, in order to clean up. This seems to have been deprecated and
made final in version 1.3. Is it neccesary to make it final?
 
Otherwise many thanks for your hard work in producing an excellent
logging system.
 
Cheers,
 
Alex


--
This e-mail is confidential and the information contained in it may be privileged.  It should not be read, copied or used by anyone other than the intended recipient.  If you have received it in error, please contact the sender immediately by telephoning +44 (0)20 7623 8000 or by return email, and delete the e-mail and do not disclose its contents to any person.  We believe, but do not warrant, that this e-mail and any attachments are virus free, but you must take full responsibility for virus checking.  Please refer to http://www.dresdnerkleinwort.com/disc/email/ and read our e-mail disclaimer statement and monitoring policy.

Dresdner Kleinwort is the trading name of the investment banking division of Dresdner Bank AG, and operates through Dresdner Bank AG, Dresdner Kleinwort Limited, Dresdner Kleinwort Securities Limited and their affiliated or associated companies.  Dresdner Bank AG is a company incorporated in Germany with limited liability and registered in England (registered no. FC007638, place of business 30 Gresham Street, London EC2V 7PG), and is authorised by the German Federal Financial Supervisory Authority and by the Financial Services Authority ('FSA') and regulated by the FSA for the conduct of designated business in the UK.  Dresdner Kleinwort Limited is a company incorporated in England (registered no. 551334, registered office 30 Gresham Street, London EC2V 7PG), and is authorised and regulated by the FSA.  Dresdner Kleinwort Securities Limited is a company incorporated in England (registered no. 1767419, registered office 30 Gresham Street, London EC2V 7PG), and is authorised and regulated by the FSA.


Re: log4j Timezones

Posted by Curt Arnold <ca...@apache.org>.
On Jul 23, 2007, at 11:00 AM, Hill, Alex wrote:

> Hi Curt,
>
> Thanks for such a prompt reply.
>
> I've had a look at the new RollingFileAppender & the
> TimeBasedRollingPolicy and they look good to me. Unfortunately I work
> for a bank and they're pretty cautious about using alpha versions in
> production evironments. Do you have a feel for when we might expect a
> full release?

It is more of a process issue than technical issue at the moment.  I  
do not think it is likely for log4j 1.2.15 or the companions to come  
to a vote until the Chainsaw developers are ready for a release of  
Chainsaw.  Hopefully we can get that out in the next month.  However  
any feedback you can provide on the release candidates is very welcome.


>
> I understand the potential problems with deleting old log files and  
> can
> appreciate why log4j wouldn't attempt a generic solution. It wasn't  
> too
> hard to produce a solution to meet our particular needs extending the
> DailyRollingFileAppender. I will probably just adapt it to extend the
> RollingFileAppender later on when a full release comes out.
>
> I just noticed that in the javadoc I have for 1.3 alpha 8
> RollingFileAppender is marked final. Is this still the case? Looks  
> like
> TimeBasedRollingPolicy is marked final too so I couldn't extend that.
> Would seem a shame if I had to rewrite the time based rolling logic  
> you
> guys already have in my own custom appender.
>

No, it is no longer final in log4j 1.3.  Currently, the log4j 1.3 SVN  
HEAD contains a port of the log4j 1.2 o.a.l.RFA and o.a.l.DRFA.  Just  
before alpha 8, versions of o.a.l.RFA and DRFA that delegated to  
o.a.l.rolling.RFA were written to provide a migration path for users  
of the log4j 1.2 RFA and DRFA.  However, as those were just a proxy  
to o.a.l.rolling.RFA, any extensions based on the log4j 1.2 code  
would not work.  Prior to that, log4j 1.3 had no implementation of  
o.a.l.RFA and DRFA and you were forced to migrate to  
o.a.l.rolling.RollingFileAppender.

However, log4j 1.3 development is suspended and whatever is in the  
log4j 1.3 alphas or SVN should only be of archaeological interested.   
Users of log4j 1.3 alphas, should plan to migrate to either log4j 1.2  
(likely using one or more of the companions to get features that had  
only been available in log4j 1.3) or to log4j 2.0 (which is still in  
exploratory development).

I know the website still reflects the status likely nearly two years  
ago.  A preview of the new LS web site can be browsed at http:// 
svn.apache.org/repos/asf/logging/site/trunk/docs/index.html.



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


RE: log4j Timezones

Posted by "Hill, Alex" <Al...@dkib.com>.
Hi Curt,

Thanks for such a prompt reply. 

I've had a look at the new RollingFileAppender & the
TimeBasedRollingPolicy and they look good to me. Unfortunately I work
for a bank and they're pretty cautious about using alpha versions in
production evironments. Do you have a feel for when we might expect a
full release?

I understand the potential problems with deleting old log files and can
appreciate why log4j wouldn't attempt a generic solution. It wasn't too
hard to produce a solution to meet our particular needs extending the
DailyRollingFileAppender. I will probably just adapt it to extend the
RollingFileAppender later on when a full release comes out. 

I just noticed that in the javadoc I have for 1.3 alpha 8
RollingFileAppender is marked final. Is this still the case? Looks like
TimeBasedRollingPolicy is marked final too so I couldn't extend that.
Would seem a shame if I had to rewrite the time based rolling logic you
guys already have in my own custom appender.

Cheers,

Alex 

-----Original Message-----
From: Curt Arnold [mailto:carnold@apache.org] 
Sent: 20 July 2007 16:08
To: Log4J Users List
Subject: Re: log4j Timezones


On Jul 20, 2007, at 7:33 AM, Hill, Alex wrote:

> Hi,
>
> I'm currently using log4j 1.2.14 and have been having some trouble 
> logging in GMT. Is there any way of setting the timezone of an 
> appender?
> I ended up doing this:
>
>     TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
>
> This seems to work but it means my appender has to set this property 
> globally. This isn't ideal as it may cause unexpected results in any 
> applications using my appender.
>
> I saw somewhere that ConversionPattern has been extended in version
> 1.3
> to take a second parameter for a timezone such as below:
>
>     log4j.appender.FILE.layout.conversionPattern   = %d{yyyy-MM-dd
> hh:mm:ss z}{GMT+0} %-5p [%c{1}:%t] %m%n
>

The log4j 1.3 PatternLayout has been backported for use with log4j
1.2 as part of the "extras" companion which has not yet been released.
A release candidate is available at http://
people.apache.org/builds/logging/log4j/companions/extras/1.0/.  Place
the apache-log4j-extras-1.0.jar in the classpath and change the class
name from o.a.l.PatternLayout to o.a.l.EnhancedPatternLayout and you
should have all of the log4j 1.3 pattern features.  I would appreciate
any feedback on the release candidate reported to log4j-dev.


> Will this mean that the time based rolling appenders will roll 
> correctly at the end of day as specified by the time zone or is this 
> purely for the date text in the log? Is there a better way to specify 
> the timezone properly?

The extras companions also include the log4j 1.3
org.apache.log4j.rolling RollingFileAppenders.  I need to make sure that
they use the EnhancedPatternLayout, but they should be able to roll at
midnight local time.  The stock DailyRollingFileAppender however isn't
affected by the presence of the enhanced pattern layout.

>
> I extended the DailyRollingFileAppender to delete out of date files, 
> as it rolls, in order to clean up. This seems to have been deprecated 
> and made final in version 1.3. Is it neccesary to make it final?
>

You may be looking at log4j 1.3 at the time DailyRollingFileAppender was
rewritten to delegate to org.apache.log4j.rolling.RollingFileAppender
(at least it was an improvement over not having DRFA at all).  The
current SVN HEAD does mark DRFA as deprecated and has some minor other
changes, but it is not marked final.

Deleting out of date files have always been problematic since you could
easily use a date pattern than omitted significant parts of the date and
you couldn't infer the actual time from the file name.  I'd suggest
using the o.a.l.rolling.RFA with an custom TriggeringPolicy.

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


--
This e-mail is confidential and the information contained in it may be privileged.  It should not be read, copied or used by anyone other than the intended recipient.  If you have received it in error, please contact the sender immediately by telephoning +44 (0)20 7623 8000 or by return email, and delete the e-mail and do not disclose its contents to any person.  We believe, but do not warrant, that this e-mail and any attachments are virus free, but you must take full responsibility for virus checking.  Please refer to http://www.dresdnerkleinwort.com/disc/email/ and read our e-mail disclaimer statement and monitoring policy.

Dresdner Kleinwort is the trading name of the investment banking division of Dresdner Bank AG, and operates through Dresdner Bank AG, Dresdner Kleinwort Limited, Dresdner Kleinwort Securities Limited and their affiliated or associated companies.  Dresdner Bank AG is a company incorporated in Germany with limited liability and registered in England (registered no. FC007638, place of business 30 Gresham Street, London EC2V 7PG), and is authorised by the German Federal Financial Supervisory Authority and by the Financial Services Authority ('FSA') and regulated by the FSA for the conduct of designated business in the UK.  Dresdner Kleinwort Limited is a company incorporated in England (registered no. 551334, registered office 30 Gresham Street, London EC2V 7PG), and is authorised and regulated by the FSA.  Dresdner Kleinwort Securities Limited is a company incorporated in England (registered no. 1767419, registered office 30 Gresham Street, London EC2V 7PG), and is authorised and regulated by the FSA.


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


Re: log4j Timezones

Posted by Curt Arnold <ca...@apache.org>.
On Jul 20, 2007, at 7:33 AM, Hill, Alex wrote:

> Hi,
>
> I'm currently using log4j 1.2.14 and have been having some trouble
> logging in GMT. Is there any way of setting the timezone of an  
> appender?
> I ended up doing this:
>
>     TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
>
> This seems to work but it means my appender has to set this property
> globally. This isn't ideal as it may cause unexpected results in any
> applications using my appender.
>
> I saw somewhere that ConversionPattern has been extended in version  
> 1.3
> to take a second parameter for a timezone such as below:
>
>     log4j.appender.FILE.layout.conversionPattern   = %d{yyyy-MM-dd
> hh:mm:ss z}{GMT+0} %-5p [%c{1}:%t] %m%n
>

The log4j 1.3 PatternLayout has been backported for use with log4j  
1.2 as part of the "extras" companion which has not yet been  
released.  A release candidate is available at http:// 
people.apache.org/builds/logging/log4j/companions/extras/1.0/.  Place  
the apache-log4j-extras-1.0.jar in the classpath and change the class  
name from o.a.l.PatternLayout to o.a.l.EnhancedPatternLayout and you  
should have all of the log4j 1.3 pattern features.  I would  
appreciate any feedback on the release candidate reported to log4j-dev.


> Will this mean that the time based rolling appenders will roll  
> correctly
> at the end of day as specified by the time zone or is this purely for
> the date text in the log? Is there a better way to specify the  
> timezone
> properly?

The extras companions also include the log4j 1.3  
org.apache.log4j.rolling RollingFileAppenders.  I need to make sure  
that they use the EnhancedPatternLayout, but they should be able to  
roll at midnight local time.  The stock DailyRollingFileAppender  
however isn't affected by the presence of the enhanced pattern layout.

>
> I extended the DailyRollingFileAppender to delete out of date  
> files, as
> it rolls, in order to clean up. This seems to have been deprecated and
> made final in version 1.3. Is it neccesary to make it final?
>

You may be looking at log4j 1.3 at the time DailyRollingFileAppender  
was rewritten to delegate to  
org.apache.log4j.rolling.RollingFileAppender (at least it was an  
improvement over not having DRFA at all).  The current SVN HEAD does  
mark DRFA as deprecated and has some minor other changes, but it is  
not marked final.

Deleting out of date files have always been problematic since you  
could easily use a date pattern than omitted significant parts of the  
date and you couldn't infer the actual time from the file name.  I'd  
suggest using the o.a.l.rolling.RFA with an custom TriggeringPolicy.

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