Sponsoring The Perl Toolchain Summit 2025: Help make this important event another success Learn more

#!/usr/bin/perl
######################################################################
# override_appender -- 2003, Mike Schilli <m@perlmeister.com>
######################################################################
# Overrided the appender layout after defining it in the conf file.
######################################################################
use strict;
my $VERSION = "0.01";
our $CVSVERSION = '$Revision: 1.1 $';
use Log::Log4perl qw(:easy);
Log::Log4perl->init(\ <<'EOT');
log4perl.category = WARN, Screen
log4perl.appender.Screen = Log::Log4perl::Appender::Screen
log4perl.appender.Screen.layout = \
Log::Log4perl::Layout::PatternLayout
log4perl.appender.Screen.layout.ConversionPattern = %d %F{1} %L> %m %n
EOT
my $appenders = Log::Log4perl->appenders();
my $layout = Log::Log4perl::Layout::PatternLayout->new("%m %m%n");
$appenders->{Screen}->layout($layout);
WARN("test message");
__END__
=head1 NAME
override_appender - Try to change an appender's layout
=head1 SYNOPSIS
override_appender
=head1 DESCRIPTION
Change an appender's layout after it has been defined in the configuration
file.
=head1 LICENSE
Copyright 2002-2013 by Mike Schilli E<lt>m@perlmeister.comE<gt>
and Kevin Goess E<lt>cpan@goess.orgE<gt>.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=head1 AUTHOR
Please contribute patches to the project on Github:
Send bug reports or requests for enhancements to the authors via our
MAILING LIST (questions, bug reports, suggestions/patches):
log4perl-devel@lists.sourceforge.net
Authors (please contact them via the list above, not directly):
Mike Schilli <m@perlmeister.com>,
Kevin Goess <cpan@goess.org>
Contributors (in alphabetical order):
Ateeq Altaf, Cory Bennett, Jens Berthold, Jeremy Bopp, Hutton
Davidson, Chris R. Donnelly, Matisse Enzer, Hugh Esco, Anthony
Foiani, James FitzGibbon, Carl Franks, Dennis Gregorovic, Andy
Grundman, Paul Harrington, Alexander Hartmaier David Hull,
Robert Jacobson, Jason Kohles, Jeff Macdonald, Markus Peter,
Brett Rann, Peter Rabbitson, Erik Selberg, Aaron Straup Cope,
Lars Thegler, David Viner, Mac Yang.