++ed by:
1 non-PAUSE user
Author image Andrew Johnson
and 1 contributors


HeliosX::Logger::Log4perl - Helios::Logger subclass implementing logging to Log4perl for Helios


 # in your helios.ini
 # log4perl supports lots of options, so you can get creative
 # e.g. log everything to log4perl, 
 # but specify which services go to which categories
 # log all the MyApp::* services to the same log4perl category 
 # we won't specify a category here, so Helios will default to category 'YourApp'


This class implements a Helios::Logger class to provide Helios applications the logging capabilities of Log4perl.

For information about configuring Log4perl, see the Log::Log4perl documentation.


log4perl_conf [REQUIRED]

The location of the Log4perl configuration file. If specified in your helios.ini [global] section, the conf file will apply to all of your Helios services. You may also configure different conf files for specific services by placing the log4perl_conf line in an individual service's helios.ini section.

See the Log4perl documentation for details about configuring Log4perl itself.


The Log4perl "category" to log messages for this service. If declared in your helios.ini [global] section, all Helios services will send log messages to the specified category. If specified in a single service's section, only that service will send log messages to the specified category. You may also declare a default category in the [global] section, and specific categories for particular Helios services, allowing certain services to log to their own category but others to default to the global one.

If log4perl_category is not specified, the Log4perl category will default to the name of your service class.


If specified, Log4perl will reread the log4perl_conf file after the given number of seconds and update its configuration accordingly. If this isn't specified, any changes to your conf file will require you to restart your service daemon to pick up the new configuration.


Just like log_priority_threshold, but for syslogd. If you just want to log messages of a certain priority or higher, you can set a numeric value for log4perl_priority_threshold and any log messages of a higher value (lower priority) will be discarded. The priority levels are defined in Helios::LogEntry::Levels.

Priority Translation

Helios was originally developed using Sys::Syslog as its primary logging system. It eventually developed its own internal logging subsystem, and Helios 2.30 added the Helios::Logger interface to further modularize Helios's logging capabilities and make it useful in more environments. Due to this history, however, Helios defines 8 logging priorities versus Log4perl's 5. HeliosX::Logger::Log4perl translates on-the-fly several of the priority levels defined in Helios::LogEntry::Levels to Log4perl's levels:

 numeric value  Helios::LogEntry::Levels   Log::Log4perl::Level
 0              LOG_EMERG                  $FATAL
 1              LOG_ALERT                  $FATAL
 2              LOG_CRIT                   $FATAL
 3              LOG_ERR                    $ERROR
 4              LOG_WARNING                $WARN
 5              LOG_NOTICE                 $INFO
 6              LOG_INFO                   $INFO
 7              LOG_DEBUG                  $DEBUG


init($config, $jobType)

The init() method verifies log4perl_conf is set in helios.ini and can be read. It then calls Log::Log4perl::init() or (if log4perl_watch_interval is set) Log::Log4perl::init_and_watch() to set up the Log4perl system for logging.

logMsg($job, $priority_level, $message)

The logMsg() method logs the given message to the configured log4perl_category with the given $priority_level.

assembleMsg($job, $priority_level, $msg)

Given the information passed to logMsg(), assembleMsg() returns the text string to be logged to the Log4perl category. Separating this step into its own method allows you to easily override the default message format if you so choose. Simply subclass HeliosX::Logger::Log4perl and override assembleMsg() with your own message formatting method.


Helios::Service, HeliosX::Logger, Log::Log4perl


Andrew Johnson, <lajandy at cpan dotorg>


Copyright (C) 2009-12 by Andrew Johnson

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.0 or, at your option, any later version of Perl 5 you may have available.


This software comes with no warranty of any kind.