Both Log::Contextual and Log::Any are designed to be generic logging "routers" for module authors to use, such that the top-level script can decide where to direct the messages.
They take slightly different stances: Log::Contextual throws an exception if no logging destination gets configured, so every module/distribution that uses it needs to also specify some kind of default logging behavior when first initialized. You can make it so that the default does not override whatever the top-level script decided to do. This can make the boilerplate for your modules a bit ugly.
Log::Any takes the opposite position, and all log messages are discarded by default unless someone directs them somewhere. This can mean that someone uses your module and can't figure out why it isn't working, because they aren't seeing any of the warnings and don't know that they need to configure Log::Any::Adapter to see them.
Log::Any has no non-core dependencies. Log::Contextual is also pretty light, but depends on Moo and some other small stuff.
I work on a large project that uses both - it means that the utility scripts I write need to hook into *both* log streams in order to see the full logging generated by the modules. Having used both, I think I like Log::Any a little better, but it's only a small preference.
Whatever you do, don't try to integrate Log4Perl or a full-featured logger into a *module*, because then all users of your module have to wrangle the configuration for it.
One final option is to not use any library, and expect the user of the object to supply the logger as an attribute. This is the approach I took in my https://metacpan.org/pod/Data::TableReader#log, since I expect most people want to capture the log messages into an array (to respond to web-submitted data). Both Log::Any and Log::Contextual make it a bit difficult to *temporarily capture* log messages into an array.
|