.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" 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" '' . ds C` . ds C' '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 >0, 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. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Perlbal::Manual::Logging 3pm" .TH Perlbal::Manual::Logging 3pm "2022-06-28" "perl v5.34.0" "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 MOST IMPORTANT THING TO KNOW ABOUT PERLBAL\s0'S \s-1LOGGING SYSTEM.\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 ALSO\s0" .IX Subsection "SEE ALSO" You can tweek Sys::Syslog's configuration under \fI/etc/syslog.conf\fR. See Sys::Syslog for more details.