.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Perlbal::Manual::Logging 3pm" .TH Perlbal::Manual::Logging 3pm "2012-03-23" "perl v5.14.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Perlbal::Manual::Logging \- How Perlbal's logging system works .SS "\s-1VERSION\s0" .IX Subsection "VERSION" Perlbal 1.78. .SS "\s-1DESCRIPTION\s0" .IX Subsection "DESCRIPTION" Perlbal supports logging of a few messages (and you can log your messages in your plugins, for instance). .PP This document describes how to achieve that. .SS "\s-1IMPORTANT:\s0 foreground vs. background" .IX Subsection "IMPORTANT: foreground vs. background" If Perlbal is running on the foreground, it logs by calling \f(CW\*(C`printf\*(C'\fR, which means you should get the logs on \f(CW\*(C`STDOUT\*(C'\fR. .PP If Perlbal is running on the background, it logs through Sys::Syslog. If Sys::Syslog is not available, there will be no logging, and \s-1THAT\s0'S \s-1THE\s0 \s-1MOST\s0 \s-1IMPORTANT\s0 \s-1THING\s0 \s-1TO\s0 \s-1KNOW\s0 \s-1ABOUT\s0 \s-1PERLBAL\s0'S \s-1LOGGING\s0 \s-1SYSTEM\s0. .SS "How to log a message" .IX Subsection "How to log a message" You can log a message by calling \f(CW\*(C`Perlbal::log\*(C'\fR as you'd call Sys::Syslog's \f(CW\*(C`syslog\*(C'\fR: .PP .Vb 1 \& Perlbal::log( $priority, $format, @args ); .Ve .PP You should read the documentation for Sys::Syslog for more information, but here's an example: .PP .Vb 1 \& Perlbal::log( \*(Aqinfo\*(Aq, \*(Aqbeginning run\*(Aq ); .Ve .PP And here's another example: .PP .Vb 1 \& Perlbal::log( \*(Aqcrit\*(Aq, "this thing crashed: $!" ); .Ve .SS "What is logged?" .IX Subsection "What is logged?" .IP "\(bu" 4 When we try to read from or write to a filehandle that is undefined, Perlbal::AIO logs a critical message: .Sp .Vb 1 \& Perlbal::log("crit", "Undef \e$fh: $stack_trace"); .Ve .IP "\(bu" 4 When failing to create a socket, Perlbal::BackendHTTP logs a critical message: .Sp .Vb 1 \& Perlbal::log(\*(Aqcrit\*(Aq, "Error creating socket: $!"); .Ve .IP "\(bu" 4 When \f(CW\*(C`inet_aton\*(C'\fR fails to create a socket, Perlbal::BackendHTTP logs a critical message: .Sp .Vb 1 \& Perlbal::log(\*(Aqcrit\*(Aq, "inet_aton failed creating socket for $ip"); .Ve .IP "\(bu" 4 When writing to a client, if we try to read more than we should from the backend, Perlbal::ClientHTTPBase logs a warning message: .Sp .Vb 1 \& Perlbal::log(\*(Aqwarning\*(Aq, "tried to readahead negative bytes. filesize=$self\->{reproxy_file_size}, offset=$self\->{reproxy_file_offset}"); .Ve .IP "\(bu" 4 When opening a file being \s-1PUT\s0 for writing to disk, if there's an error (which is going to originate a 500 server error), Perlbal::ClientHTTPBase logs a warning message: .Sp .Vb 1 \& Perlbal::log(\*(Aqwarning\*(Aq, "system error: $msg ($info)"); .Ve .IP "\(bu" 4 If we receive a request with a content length different from the actual length of the request, Perlbal::ClientProxy logs a critical message: .Sp .Vb 1 \& Perlbal::log(\*(Aqcrit\*(Aq, "Content length of $clen declared but $self\->{buoutpos} bytes written to disk"); .Ve .IP "\(bu" 4 When trying to buffer data to disk, if the operation fails Perlbal::ClientProxy logs a critical message: .Sp .Vb 1 \& Perlbal::log(\*(Aqcrit\*(Aq, "Failure to open $fn for buffered upload output"); .Ve .IP "\(bu" 4 After buffering data to disk, if the file is empty, Perlbal::ClientProxy logs a critical message: .Sp .Vb 1 \& Perlbal::log(\*(Aqcrit\*(Aq, "Error writing buffered upload: $!. Tried to do $len bytes at $self\->{buoutpos}."); .Ve .IP "\(bu" 4 When purging a buffered upload on the disk, if an error occurs, Perlbal::ClientProxy logs a critical message: .Sp .Vb 1 \& Perlbal::log(\*(Aqwarning\*(Aq, "Unable to link $self\->{bufilename}: $!"); .Ve .IP "\(bu" 4 When marking a backend as pending, if there's already another one in that ip/port, Perlbal::Service will log a couple of warning messages: .Sp .Vb 1 \& Perlbal::log(\*(Aqwarning\*(Aq, "Warning: attempting to spawn backend connection that already existed."); \& \& Perlbal::log(\*(Aqwarning\*(Aq, " \-\- [$filename:$line] $package::$subroutine"); .Ve .IP "\(bu" 4 When deciding whether we should spawn one or more backend connections, if the total of pending conections is negative, Perlbal::Service will log a critical message: .Sp .Vb 1 \& Perlbal::log(\*(Aqcrit\*(Aq, "Bogus: service $self\->{name} has pending connect count of $self\->{pending_connect_count}?! Resetting."); .Ve .IP "\(bu" 4 When spawning a backend connection, if there is no \s-1IP\s0 address for the backend, Perlbal::Service will log a critical message: .Sp .Vb 1 \& Perlbal::log(\*(Aqcrit\*(Aq, "No backend IP for service $self\->{name}"); .Ve .IP "\(bu" 4 When starting, Perlbal will log an info message: .Sp .Vb 1 \& Perlbal::log(\*(Aqinfo\*(Aq, \*(Aqbeginning run\*(Aq); .Ve .IP "\(bu" 4 When shutting down, Perlbal will log an info message: .Sp .Vb 1 \& Perlbal::log(\*(Aqinfo\*(Aq, \*(Aqending run\*(Aq); .Ve .IP "\(bu" 4 After each loop, is some error occurred, Perlbal will log a critical message: .Sp .Vb 1 \& Perlbal::log(\*(Aqcrit\*(Aq, "crash log: $_") foreach split(/\er?\en/, $@); .Ve .IP "\(bu" 4 When attempting to create the pidfile, if unsuccessful, Perlbal will log an info message: .Sp .Vb 1 \& Perlbal::log(\*(Aqinfo\*(Aq, "couldn\*(Aqt create pidfile \*(Aq$file\*(Aq: $!" ); .Ve .IP "\(bu" 4 When attempting to write to the pidfile, if unsuccessful, Perlbal will log an info message: .Sp .Vb 1 \& Perlbal::log(\*(Aqinfo\*(Aq, "couldn\*(Aqt write into pidfile \*(Aq$file\*(Aq: $!" ); .Ve .SS "Generating more logs by sending a \s-1USR1\s0 signal to perlbal" .IX Subsection "Generating more logs by sending a USR1 signal to perlbal" If you send a \s-1USR1\s0 signal to perlbal, that tells it to log some basic statistics to the syslog. .PP It's similar to connecting to a management service and issue a \f(CW\*(C`show service\*(C'\fR for each service, plus a \f(CW\*(C`states\*(C'\fR and a \f(CW\*(C`queues\*(C'\fR commands. .SS "Where is it logged to?" .IX Subsection "Where is it logged to?" The way Perlbal opens Sys::Syslog, it logs to \fI/var/log/daemon.log\fR by default. .SS "\s-1SEE\s0 \s-1ALSO\s0" .IX Subsection "SEE ALSO" You can tweek Sys::Syslog's configuration under \fI/etc/syslog.conf\fR. See Sys::Syslog for more details.