Steve Dondley


Log::Log4perl::Shortcuts - shortcut functions to make log4perl even easier


version 0.014


Provides an easy-to-use wrapper for Log::Log4perl.


Instead of this:

  use Log::Log4perl;

  sub do_something {
    my $logger = Log::Log4perl->get_logger('my.category');

    $log->info('I am doing something.');

You can save some keystrokes and do this:

  use Log::Log4perl::Shortcuts qw(:all);

  sub do_something {
    logw('I am doing something.', 'my.category');


This modules provides shortcut functions for the standard log levels provided by Log::Log4perl plus some additional functionality to make it more convenient.

Log level functions

There are the six log level functions provided, one for each of the standard log levels provided by the Log4perl module. Each of them accepts an argument for the log message plus an optional category argument.

The $category arguments, if supplied, are appended to the name of the calling package where the log command was invoked. For example, if logi('Info log entry', 'my_category') is called from package Foo::Bar, the log entry will be made with the category:

The $options arguments, if avaiable, supply addition options to the loge and logf functions. If { show_callers => 1 } is supplied, a stack trace will be printed out below the error or fatal message.



logt ($msg, [$category])

Prints a message to the trace logger when the log level is set to TRACE or above.

logd ($msg, [$category])

Print messages when the log level is set to DEBUG or above. $category argument is optional.

$msg is intended to be a scalar variable or reference to a data structure which will be output as a message after getting passed through Data::Dumper.

logi ($msg, [$category])

Prints a message to the info logger when the log level is set to INFO or above.

logw ($msg, [$category])

Prints a message to the warn logger when the log level is set to WARN or above.

loge ($msg, [$category], [{ $options => value, ... }])

Prints a message to the error logger when the log level is set to ERROR or above.

logf ($msg, [$category], [{ $options => value, ... }])

Prints a message to the fatal logger when the log level is set to FATAL or above.

Special Functions

logc ([$category])

Prints call stack when log level is set to TRACE or above. Note that no message argument is used by this function.

set_log_config ($filename)

Changes the log configuration file which must be placed in the ~/perl/log_config directory.

set_log_level ($log_level)

Change the log level. Should be one of 'trace', 'debug', 'info', 'warn', 'error', or 'fatal'.


Place any custom log configuration files you'd like to use in ~/perl/log_config and use the set_log_config function to switch to it.




You can find documentation for this module with the perldoc command.

  perldoc Log::Log4perl::Shortcuts


The following websites have more information about this module, and may be of help to you. As always, in addition to those websites please use your favorite search engine to discover more resources.

Source Code

The code is open to the world, and available for you to hack on. Please feel free to browse it and play with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull from your repository :)

  git clone git://


You can make new bug reports, and view existing ones, through the web interface at


See perlmodinstall for information and options on installing Perl modules.


Steve Dondley <>


This software is copyright (c) 2018 by Steve Dondley.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.