Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

(first time post: hope this is /reed-A-bull/...)

System: Fedora/eclipse/perl

we (work) just started using log4perl

I can't find a "flag" for the %d in ConversionPattern to add timezone? (or Daylight Savings Flag)

I found ways to find the information thru code, but then how do I add a STRING to follow ConversionPattern %d (without making this part of each and every message string?

Currently in log4perl.conf:

log4perl.appender.perllog.layout.ConversionPattern= %d{yyyyMMdd.hhmmss +:}-%P-%H-%p{2}-%m

I'd even be happy with a "GMT(+/-)##" addtion

Replies are listed 'Best First'.
Re: log4perl Timezone
by beech (Parson) on Mar 02, 2016 at 18:14 UTC
    See Log::Log4perl::Layout::PatternLayout and Log::Log4perl::DateFormat and use %d{Z}
    #!/usr/bin/perl -- use strict; use warnings; use Log::Log4perl 1.26 qw(:easy); my $logconfig = <<"__LOGCONFIG__"; log4perl.rootLogger = ALL, First log4perl.appender.First = Log::Log4perl::Appender::Screen log4perl.appender.First.layout = Log::Log4perl::Layout::PatternLayout log4perl.appender.First.layout.ConversionPattern= %d{yyyyMMdd.hhmmss:Z +}-%P-%%H-%p{2}-%m%n __LOGCONFIG__ Log::Log4perl::init( \$logconfig ); DEBUG('debug'); INFO('info'); WARN('warn'); ERROR('error'); TRACE('trace'); FATAL('fatal'); __END__ 20160302.102316:-0800-3608-%H-DE-debug 20160302.102316:-0800-3608-%H-IN-info 20160302.102316:-0800-3608-%H-WA-warn 20160302.102316:-0800-3608-%H-ER-error 20160302.102316:-0800-3608-%H-TR-trace 20160302.102316:-0800-3608-%H-FA-fatal