1Appender::ScreenColoredULseevrelCso(n3t)ributed Perl DocAupmpeenntdaetri:o:nScreenColoredLevels(3)
2
3
4
6 Log::Log4perl::Appender::ScreenColoredLevels - 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
102 Using ScreenColoredLevels on Windows
103 Note that if you're using this appender on Windows, you need to fetch
104 Win32::Console::ANSI from CPAN and add
105
106 use Win32::Console::ANSI;
107
108 to your script.
109
111 Copyright 2002-2013 by Mike Schilli <m@perlmeister.com> and Kevin Goess
112 <cpan@goess.org>.
113
114 This library is free software; you can redistribute it and/or modify it
115 under the same terms as Perl itself.
116
118 Please contribute patches to the project on Github:
119
120 http://github.com/mschilli/log4perl
121
122 Send bug reports or requests for enhancements to the authors via our
123
124 MAILING LIST (questions, bug reports, suggestions/patches):
125 log4perl-devel@lists.sourceforge.net
126
127 Authors (please contact them via the list above, not directly): Mike
128 Schilli <m@perlmeister.com>, Kevin Goess <cpan@goess.org>
129
130 Contributors (in alphabetical order): Ateeq Altaf, Cory Bennett, Jens
131 Berthold, Jeremy Bopp, Hutton Davidson, Chris R. Donnelly, Matisse
132 Enzer, Hugh Esco, Anthony Foiani, James FitzGibbon, Carl Franks, Dennis
133 Gregorovic, Andy Grundman, Paul Harrington, Alexander Hartmaier David
134 Hull, Robert Jacobson, Jason Kohles, Jeff Macdonald, Markus Peter,
135 Brett Rann, Peter Rabbitson, Erik Selberg, Aaron Straup Cope, Lars
136 Thegler, David Viner, Mac Yang.
137
138
139
140perl v5.32.1 2021-02-08 Appender::ScreenColoredLevels(3)