1POE::Component::Logger(U3s)er Contributed Perl DocumentatPiOoEn::Component::Logger(3)
2
3
4
6 POE::Component::Logger - A POE logging class
7
9 In your startup code somewhere:
10
11 POE::Component::Logger->spawn(ConfigFile => 'log.conf');
12
13 And later in an event handler:
14
15 Logger->log("Something happened!");
16
18 POE::Component::Logger provides a simple logging component that uses
19 Log::Dispatch::Config to drive it, allowing you to log to multiple
20 places at once (e.g. to STDERR and Syslog at the same time) and also to
21 flexibly define your logger's output.
22
23 It is very simple to use, because it creates a Logger::log method (yes,
24 this is namespace corruption, so shoot me). If you don't like this,
25 feel free to post directly to your logger as follows:
26
27 $kernel->post('logger', 'log', "An error occurred: $!");
28
29 In fact you have to use that method if you pass an Alias option to
30 spawn (see below).
31
32 All logging is done in the background, so don't expect immediate output
33 - the output will only occur after control goes back to the kernel so
34 it can process the next event.
35
37 spawn
38 The spawn class method can take two options. A required ConfigFile
39 option, which specifies the location of the config file as passed to
40 Log::Dispatch::Config's "configure()" method (note that you can also
41 use an object here, see Log::Dispatch::Config for more details). The
42 other available option is Alias which you can use if you wish to have
43 more than one logger in your POE application. Note though that if you
44 specify an alias other than the default 'logger' alias, you will not be
45 able to use the "Logger-<log" shortcut, and will have to use direct
46 method calls instead.
47
48 Logger->log
49 This is used to perform a logging action. You may either pass a string,
50 or a hashref. If you pass in a string it is logged at the level
51 specified in $POE::Component::Logger::DefaultLevel, which is 'warning'
52 by default. If you pass in a hashref it is passed as a hash to
53 Log::Dispatch's "log()" method.
54
56 The following states are available on the logging session:
57
58 log
59 Same as "Logger-<log()", except you may use a different alias if
60 posting direct to the kernel, for example:
61
62 $kernel->post( 'error.log', 'log', "Some error");
63 $kernel->post( 'access.log', 'log', "Access Details");
64
65 debug
66 And also "notice" "warning", "info", "error", "critical", "alert" and
67 "emergency".
68
69 These states simply log at a different level. See Log::Dispatch for
70 further details.
71
73 # logs to screen (STDERR) and syslog
74 dispatchers = screen syslog
75
76 [screen]
77 class = Log::Dispatch::Screen
78 min_level = info
79 stderr = 1
80 format = %d %m %n
81
82 [syslog]
83 class = Log::Dispatch::Syslog
84 min_level = warning
85
87 Matt Sergeant, matt@sergeant.org
88
90 Please use http://rt.cpan.org/ for bugs.
91
93 This is free software. You may use it and redistribute it under the
94 same terms as Perl itself.
95
97 Log::Dispatch
98
99 Log::Dispatch::Config
100
101 AppConfig
102
103 POE
104
105
106
107perl v5.12.0 2002-01-10 POE::Component::Logger(3)