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

# in your helios.ini loggers=HeliosX::Logger::Log4perl log4perl_conf=/path/to/log4perl.conf log4perl_category=logging.category log4perl_watch_interval=10 # log4perl supports lots of options, so you can get creative # e.g. log everything to log4perl, # but specify which services go to which categories [global] internal_logging=off loggers=HeliosX::Logger::Log4perl log4perl_conf=/etc/helios_log4perl.conf # log all the MyApp::* services to the same log4perl category [MyApp::MetajobBurstService] log4perl_category=MyApp [MyApp::IndexerService] log4perl_category=MyApp [MyApp::ReportingService] log4perl_category=MyApp [YourApp] # 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.

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 service name/jobtype (from getJobType()).
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 a service restart.

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.
The logMsg() method logs the given message to the configured log4perl_category with the given $priority_level.
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:
Helios::LogEntry::Levels Log::Log4perl::Level LOG_EMERG $FATAL LOG_ALERT $FATAL LOG_CRIT $FATAL LOG_ERR $ERROR LOG_WARNING $WARN LOG_NOTICE $INFO LOG_INFO $INFO LOG_DEBUG $DEBUG
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-11 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.