Log::ger::Manual::ForLogContextual - Log::ger for Log::Contextual users


version 0.033.000


Log::Contextual is rather popular on CPAN probably because Task::Kensho is/was displayed prominently on the MetaCPAN front page. Task::Kensho endorses Log::Contextual along with two other logging libraries: Log::Dispatch and Log::Log4perl (by the way, Log::Any, which is by far more popular and heavily used than Log::Contextual, is still somehow missing in that list).

Log::Contextual is not heavily used on CPAN, nor it is particularly efficient or featureful. Without any disrespect, in my opinion just about the only good thing about Log::Contextual is that it provides block style by default, if that's what you like:

 log_trace { "foo bar " . some_heavy_calculation() };

The block will not be executed if the log level is higher than trace, although log_trace() itself is still called.

Log::Contextual provides interface for Log::Log4perl, Log::Dispatch, Log::Dispatchouli, and some others. But this is not unique to Log::Contextual; other libraries like Log::Any or Log::ger can also use various backends.


Log::Contextual does not yet encourage separation of logging consumer and producer. You have to (or, the documentation encourages you to) set up the backend in the same place as the logging.

Log::ger is much faster and has a significantly smaller startup overhead. Although Log::Contextual's documentation mentions being "efficient" (in terms of avoiding executing the block if level is not active), Log::Contextual is not efficient in that it adds considerable logging overhead. See benchmark in Bencher::Scenarios::LogGer. I think you are better off using Log4perl directly than through Log::Contextual.

Log::ger also provides block style if you want (see Log::ger::Format::Block).



perlancar <>


This software is copyright (c) 2020, 2019, 2018, 2017 by

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