1#!/usr/bin/perl 2###################################################################### 3# override_appender -- 2003, Mike Schilli <m@perlmeister.com> 4###################################################################### 5# Overrided the appender layout after defining it in the conf file. 6###################################################################### 7use strict; 8use warnings; 9 10my $VERSION = "0.01"; 11our $CVSVERSION = '$Revision: 1.1 $'; 12 13use Log::Log4perl qw(:easy); 14Log::Log4perl->init(\ <<'EOT'); 15 log4perl.category = WARN, Screen 16 log4perl.appender.Screen = Log::Log4perl::Appender::Screen 17 log4perl.appender.Screen.layout = \ 18 Log::Log4perl::Layout::PatternLayout 19 log4perl.appender.Screen.layout.ConversionPattern = %d %F{1} %L> %m %n 20EOT 21 22my $appenders = Log::Log4perl->appenders(); 23my $layout = Log::Log4perl::Layout::PatternLayout->new("%m %m%n"); 24$appenders->{Screen}->layout($layout); 25WARN("test message"); 26 27__END__ 28 29=head1 NAME 30 31 override_appender - Try to change an appender's layout 32 33=head1 SYNOPSIS 34 35 override_appender 36 37=head1 DESCRIPTION 38 39Change an appender's layout after it has been defined in the configuration 40file. 41 42=head1 LICENSE 43 44Copyright 2002-2012 by Mike Schilli E<lt>m@perlmeister.comE<gt> 45and Kevin Goess E<lt>cpan@goess.orgE<gt>. 46 47This library is free software; you can redistribute it and/or modify 48it under the same terms as Perl itself. 49 50=head1 AUTHOR 51 52Please contribute patches to the project on Github: 53 54 http://github.com/mschilli/log4perl 55 56Send bug reports or requests for enhancements to the authors via our 57 58MAILING LIST (questions, bug reports, suggestions/patches): 59log4perl-devel@lists.sourceforge.net 60 61Authors (please contact them via the list above, not directly): 62Mike Schilli <m@perlmeister.com>, 63Kevin Goess <cpan@goess.org> 64 65Contributors (in alphabetical order): 66Ateeq Altaf, Cory Bennett, Jens Berthold, Jeremy Bopp, Hutton 67Davidson, Chris R. Donnelly, Matisse Enzer, Hugh Esco, Anthony 68Foiani, James FitzGibbon, Carl Franks, Dennis Gregorovic, Andy 69Grundman, Paul Harrington, David Hull, Robert Jacobson, Jason Kohles, 70Jeff Macdonald, Markus Peter, Brett Rann, Peter Rabbitson, Erik 71Selberg, Aaron Straup Cope, Lars Thegler, David Viner, Mac Yang. 72 73