The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

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

VERSION

version 0.028.006

WHY LOG::CONTEXTUAL

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.

WHY LOG::GER OVER LOG::CONTEXTUAL

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).

FAQ

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2019, 2018, 2017 by perlancar@cpan.org.

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