1Appender::ScreenColoredULseevrelCso(n3t)ributed Perl DocAupmpeenntdaetri:o:nScreenColoredLevels(3)
2
3
4
6 Log::Log4perl::Appender::ScreenColoredLevel - Colorize messages
7 according to level
8
10 use Log::Log4perl qw(:easy);
11
12 Log::Log4perl->init(\ <<'EOT');
13 log4perl.category = DEBUG, Screen
14 log4perl.appender.Screen = \
15 Log::Log4perl::Appender::ScreenColoredLevels
16 log4perl.appender.Screen.layout = \
17 Log::Log4perl::Layout::PatternLayout
18 log4perl.appender.Screen.layout.ConversionPattern = \
19 %d %F{1} %L> %m %n
20 EOT
21
22 # Appears black
23 DEBUG "Debug Message";
24
25 # Appears green
26 INFO "Info Message";
27
28 # Appears blue
29 WARN "Warn Message";
30
31 # Appears magenta
32 ERROR "Error Message";
33
34 # Appears red
35 FATAL "Fatal Message";
36
38 This appender acts like Log::Log4perl::Appender::Screen, except that it
39 colorizes its output, based on the priority of the message sent.
40
41 You can configure the colors and attributes used for the different
42 levels, by specifying them in your configuration:
43
44 log4perl.appender.Screen.color.TRACE=cyan
45 log4perl.appender.Screen.color.DEBUG=bold blue
46
47 You can also specify nothing, to indicate that level should not have
48 coloring applied, which means the text will be whatever the default
49 color for your terminal is. This is the default for debug messages.
50
51 log4perl.appender.Screen.color.DEBUG=
52
53 You can use any attribute supported by Term::ANSIColor as a
54 configuration option.
55
56 log4perl.appender.Screen.color.FATAL=\
57 bold underline blink red on_white
58
59 The commonly used colors and attributes are:
60
61 attributes
62 BOLD, DARK, UNDERLINE, UNDERSCORE, BLINK
63
64 colors
65 BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE
66
67 background colors
68 ON_BLACK, ON_RED, ON_GREEN, ON_YELLOW, ON_BLUE, ON_MAGENTA,
69 ON_CYAN, ON_WHITE
70
71 See Term::ANSIColor for a complete list, and information on which are
72 supported by various common terminal emulators.
73
74 The default values for these options are:
75
76 Trace
77 Yellow
78
79 Debug
80 None (whatever the terminal default is)
81
82 Info
83 Green
84
85 Warn
86 Blue
87
88 Error
89 Magenta
90
91 Fatal
92 Red
93
94 The constructor "new()" takes an optional parameter "stderr", if set to
95 a true value, the appender will log to STDERR. If "stderr" is set to a
96 false value, it will log to STDOUT. The default setting for "stderr" is
97 1, so messages will be logged to STDERR by default. The constructor
98 can also take an optional parameter "color", whose value is a hashref
99 of color configuration options, any levels that are not included in the
100 hashref will be set to their default values.
101
103 Copyright 2002-2009 by Mike Schilli <m@perlmeister.com> and Kevin Goess
104 <cpan@goess.org>.
105
106 This library is free software; you can redistribute it and/or modify it
107 under the same terms as Perl itself.
108
109
110
111perl v5.12.2 2010-08-31 Appender::ScreenColoredLevels(3)