Perl - Logging

perl

What are the available log levels?

error, warn, info, debug, trace

As listed, the severity decreases from left to right, and verbosity increases. When we talk about increasing the log level, we mean to crank up the verbosity. Here are the meaning of each level for us:

error: is for catastrophic incident where the program can't continue.
warn: is for abnormal things
info:  information
debug: is for debugging (normally used in development environment)
trace: is for debugging, but more verbose

Sample log configuration file?

log4perl.rootLogger                 = DEBUG, File

#log4perl.category.Proxy             = DEBUG
log4perl.category.Proxy.replace_url = ERROR
log4perl.category.Proxy.new = ERROR
log4perl.category.Proxy.get_cookies = ERROR
log4perl.category.Proxy.makeCacheFileNameFromURL = ERROR
log4perl.category.Proxy.isAdvertisement = DEBUG
log4perl.category.Proxy.parse_javascript = ERROR
log4perl.category.Proxy.isCacheable = ERROR
log4perl.category.Proxy.print_captured_javascript = ERROR
log4perl.category.Proxy.send_received_content_to_browser = TRACE
#log4perl.category.Proxy.endCaptureError     = DEBUG
log4perl.category.Utils             = DEBUG
log4perl.category.Utils.parse_yaml_file = ERROR
log4perl.category.Utils.connect_to_db = ERROR
log4perl.category.Utils.new = ERROR
log4perl.category.Utils.decryptCookie = ERROR
log4perl.category.Utils.encryptCookie = ERROR
log4perl.category.Utils.doNotEscapePathQuery = ERROR
log4perl.category.Utils.getHostNameFromURL = ERROR
log4perl.category.Utils.isApplicationURL = ERROR
log4perl.category.Utils.remove_mg_params = ERROR
log4perl.category.Utils.encryptGeniusIDs = ERROR
log4perl.category.Utils.getExtension = INFO
log4perl.category.DB                = ERROR
log4perl.category.Trans                = ERROR
log4perl.category.HTMLHandlers                = INFO

log4perl.appender.Screen            = Log::Log4perl::Appender::Screen
log4perl.appender.Screen.stderr     = 1
log4perl.appender.Screen.layout     = Log::Log4perl::Layout::PatternLayout
log4perl.appender.Screen.layout.ConversionPattern   = %p %c:%L> %m%n

log4perl.appender.File              = Log::Log4perl::Appender::File
log4perl.appender.File.filename     = /home/khai/www/logs/error_log
log4perl.appender.File.layout       = Log::Log4perl::Layout::PatternLayout
log4perl.appender.File.layout.ConversionPattern     = [%d] %p %c:%L> %m%n

log4perl.appender.Buzzsaw           = MG::BuzzsawSocket
log4perl.appender.Buzzsaw.PeerAddr  = 192.168.30.23
log4perl.appender.Buzzsaw.PeerPort  = 51400
log4perl.appender.Buzzsaw.layout    = MG::BuzzsawXML
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License