[log4perl-devel] Different log layout per level ?
Hello, I recently started toying with log4perl, and incorporated it in an application. I need the capability to define a log layout for WARN messages that is a lot more user-friendly/readable than the others. After reading the documentation at: http://log4perl.sourceforge.net/releases/Log-Log4perl/docs/html/Log/Log4perl.html#1d6b5 and the tutorial, I haven't seen a way to define such different layouts per level. Did I just miss it ? Is this possible using log4perl ? Thanks, Kristis signature.asc Description: This is a digitally signed message part - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ log4perl-devel mailing list log4perl-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/log4perl-devel
Re: [log4perl-devel] Different log layout per level ?
It's possible, but it's probably less than straightforward. Each appender has exactly one layout, so what you'll need to do is create two appenders, and use some combination of thresholds and filters so that one appender only logs WARN messages and the other appender logs everything else. On Feb 8, 2008, at 5:01 PM, Kristis Makris wrote: > Hello, > > I recently started toying with log4perl, and incorporated it in an > application. I need the capability to define a log layout for WARN > messages that is a lot more user-friendly/readable than the others. > > After reading the documentation at: > > http://log4perl.sourceforge.net/releases/Log-Log4perl/docs/html/Log/ > Log4perl.html#1d6b5 > > and the tutorial, I haven't seen a way to define such different > layouts > per level. Did I just miss it ? Is this possible using log4perl ? > > Thanks, > Kristis > -- > --- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ > ___ > log4perl-devel mailing list > log4perl-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/log4perl-devel -- Kevin M. Goess (and Anne and Frank) 904 Carmel Ave. Albany, CA 94706 (510) 525-5217 - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ log4perl-devel mailing list log4perl-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/log4perl-devel
Re: [log4perl-devel] Different log layout per level ?
On Sat, 9 Feb 2008, Kevin M. Goess wrote: > It's possible, but it's probably less than straightforward. Each > appender has exactly one layout, so what you'll need to do is create > two appenders, and use some combination of thresholds and filters so > that one appender only logs WARN messages and the other appender logs > everything else. Exactly, something along these lines: use Log::Log4perl qw(:easy); my $conf = q{ log4perl.logger = DEBUG, AppWarn, AppRest # Filter to match level WARN log4perl.filter.MatchWarn = Log::Log4perl::Filter::LevelMatch log4perl.filter.MatchWarn.LevelToMatch = WARN log4perl.filter.MatchWarn.AcceptOnMatch = true # Filter to match everything but WARN log4perl.filter.MatchRest = Log::Log4perl::Filter::LevelMatch log4perl.filter.MatchRest.LevelToMatch = WARN log4perl.filter.MatchRest.AcceptOnMatch = false # Elaborate layout for WARN messages log4perl.appender.AppRest = Log::Log4perl::Appender::Screen log4perl.appender.AppRest.layout = PatternLayout log4perl.appender.AppRest.layout.ConversionPattern = %F-%L %m%n log4perl.appender.AppRest.Filter = MatchWarn # Normal layout for the rest log4perl.appender.AppWarn = Log::Log4perl::Appender::Screen log4perl.appender.AppWarn.layout = PatternLayout log4perl.appender.AppWarn.layout.ConversionPattern: %m%n log4perl.appender.AppWarn.Filter = MatchRest }; Log::Log4perl->init(\$conf); DEBUG "debug message"; WARN "warn message"; ERROR "error message"; will print debug message ./t-38 warn message error message -- Mike Mike Schilli [EMAIL PROTECTED] - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ log4perl-devel mailing list log4perl-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/log4perl-devel