Log::Log4perl::AutoInit - Log4Perl with autoinitialization.
use Log::Log4perl::AutoInit qw(get_logger); Log::Log4perl::AutoInit->set_config('path/to/l4p.conf'); get_logger->warning('l4p initialized and warning logged');
This module provides a simple wrapper around Log::Log4perl for cases where initialization may need to be delayed until a statup process is complete, but where configuration may need to be registered before that point. In essence it provides a way to delay logger initialization until the logger is actually needed or used.
A key use for this is for daemons where configuration may be set on loading a Perl module, but where file handles may be subsequently closed. This module allows you to delay initialization until you are actually logging, with an ability to initialize the logger at a specific point and reinitialize if necessary.
This API sets the configuration for subsequent logger initialization. This only caches the config and does no initialization itself. This is safe to call at any point in the program but if logging is already being done, you must reinitialize (see initialize_now() below).
Sets the default category for all future loggers. If not found the callers' module name is used. To unset pass in undef.
Initializes, if necessary, and returns a logger with the identical syntax to Log4perl::get_logger(). If you close the file handles out from under the logger, you must reinitialize immediately after. See initialize_now() below.
This initializes Log4perl. If $reinitialize is set, it allows Log4perl to be explicitly reinitialized. This can be used to force a reinitialization, for example after file handles have been closed or after a configuration change.
Please report any bugs or feature requests to
bug-log-log4perl-autoinit at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Log-Log4perl-AutoInit. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
You can also look for information at: