1Level(3) User Contributed Perl Documentation Level(3)
2
3
4
6 Log::Log4perl::Level - Predefined log levels
7
9 use Log::Log4perl::Level;
10 print $ERROR, "\n";
11
12 # -- or --
13
14 use Log::Log4perl qw(:levels);
15 print $ERROR, "\n";
16
18 "Log::Log4perl::Level" simply exports a predefined set of Log4perl log
19 levels into the caller's name space. It is used internally by
20 "Log::Log4perl". The following scalars are defined:
21
22 $OFF
23 $FATAL
24 $ERROR
25 $WARN
26 $INFO
27 $DEBUG
28 $TRACE
29 $ALL
30
31 "Log::Log4perl" also exports these constants into the caller's
32 namespace if you pull it in providing the ":levels" tag:
33
34 use Log::Log4perl qw(:levels);
35
36 This is the preferred way, there's usually no need to call
37 "Log::Log4perl::Level" explicitely.
38
39 The numerical values assigned to these constants are purely virtual,
40 only used by Log::Log4perl internally and can change at any time, so
41 please don't make any assumptions.
42
43 If the caller wants to import these constants into a different
44 namespace, it can be provided with the "use" command:
45
46 use Log::Log4perl::Level qw(MyNameSpace);
47
48 After this $MyNameSpace::ERROR, $MyNameSpace::INFO etc. will be
49 defined accordingly.
50
51 Numeric levels and Strings
52 Level variables like $DEBUG or $WARN have numeric values that are
53 internal to Log4perl. Transform them to strings that can be used in a
54 Log4perl configuration file, use the c<to_level()> function provided by
55 Log::Log4perl::Level:
56
57 use Log::Log4perl qw(:easy);
58 use Log::Log4perl::Level;
59
60 # prints "DEBUG"
61 print Log::Log4perl::Level::to_level( $DEBUG ), "\n";
62
63 To perform the reverse transformation, which takes a string like
64 "DEBUG" and converts it into a constant like $DEBUG, use the
65 to_priority() function:
66
67 use Log::Log4perl qw(:easy);
68 use Log::Log4perl::Level;
69
70 my $numval = Log::Log4perl::Level::to_priority( "DEBUG" );
71
72 after which $numval could be used where a numerical value is required:
73
74 Log::Log4perl->easy_init( $numval );
75
77 Copyright 2002-2009 by Mike Schilli <m@perlmeister.com> and Kevin Goess
78 <cpan@goess.org>.
79
80 This library is free software; you can redistribute it and/or modify it
81 under the same terms as Perl itself.
82
83
84
85perl v5.12.2 2010-08-31 Level(3)