Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Wanted: Opinions on Logging Frameworks

by learnedbyerror (Monk)
on Apr 15, 2018 at 18:08 UTC ( [id://1212938]=perlquestion: print w/replies, xml ) Need Help??

learnedbyerror has asked for the wisdom of the Perl Monks concerning the following question:

Oh Wise Monks, I come yet again to seek your assistance. Being a devotee of perl for several decades, I understand and appreciate perl TIMTOWDI. Different is not wrong, but sometimes it is confusing for those of use who are less enlightened, which I definitely am :(

My question today is: What are your preferences regarding the logging frameworks available in perl (Log::Log4perl, Log::Any, Log::ger, Log::Dispatch, Log::Tiny, ...) and upon what is your preference based?

The reason that I bring this question to you, in the words of the Great Monk of Music Jimmy Buffett, is because "indecision may or may not be my problem".

Over the years, I have:

  • used simple print statements
  • created a few simple logging frameworks of my own
  • learned of Log4Perl and became a devotee for a while
  • grew lazy and used Smart::Comments, not a logging framework really at all
  • ...

I am about to start on a new endeavor and as I often do when starting something new, question my own point of view and seek answers in the temple of CPAN. Most times, this brings me enlightenment and a clear path forward. I see many of the greatest monks in the history of CPAN having authored different frameworks: Log::Any(merlyn, xdg, preaction), Log::Dispatch(autarch) and Log::ger(perlancar) as examples ) I have read their words as recorded in CPAN (some monks do a better job of documentation their works than others :)). This has helped educate me on the pure existence of these frameworks; however, I now am unclear on the appropriateness of application of these frameworks. Given neither a North Star Monk(s) or a clear functional point of view, I lack understanding why one framework may be a better fit for some cases than others.

As such, I seek to understand your opinions and the basis for them. I realize that their is no right or wrong answer here. But as I have learned over the years, there are many opinions expressed here from which I have learned!

Thank you in advance for your patience with me and your responses,

lbe

Replies are listed 'Best First'.
Re: Wanted: Opinions on Logging Frameworks
by Discipulus (Canon) on Apr 15, 2018 at 21:21 UTC
    I associate in your same question being curious to ear other monks experience and opinion.

    I just would add Log::Contextual to the list: infact when I wonder, as you, about some module I firstly check what is in Task::Kensho list.

    Before other wiser monks add their experience I can say that if you already have a good experience with Log::Log4perl I see no motivation to quit it.

    As everytime it depends on what ou need and what you expect by using a module. And it relates on the cost of importing a, possibly large, framework into your application.

    You can also be intersted in some link I collected on my cell

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

      Thank you for adding Log::Contextual. It is an interesting module.

      I really appreciate your mention of Task::Kensho. I don't think to look there enough :(. As I somewhat expected, I found Log::Log4perl and Log::Dispatch; however, I was surprised to not see Log::Any. That makes me wonder if Log::Any may be an idea that hasn't had the uptake that I would have expected given its authors.

      I have bookmarked your cell - Very, Very Interesting!

      Thanks!

      lbe

        As Task::Kensho admits itself in its documentation: This list is by no means comprehensive of the "Good" Modules on CPAN. Nor is this necessarily the correct path for all developers. Each of these modules has a perfectly acceptable replacement that may work better for you. This is however a path to good perl practice, and a starting place on the road to Enlightened Perl programming. I agree that Log::Any is one among some modules that really deserves to be there. I'd even suggest that it replace Log::Contextual instead (Log::Contextual is a weird choice, it's not particularly interesting and far from widely used.)

        All in all, I view Task::Kensho as an opinionated list of recommended modules. I'd encourage people to publish their own list also.

Re: Wanted: Opinions on Logging Frameworks
by 1nickt (Canon) on Apr 16, 2018 at 14:35 UTC

    Hi, FYI you can use Log::Any as the logger and Log::Dispatch as the output adapter, which then allows you to output to different destinations (file + screen for example).

    Edit: Also you can use Log::Log4perl as the output adapter for Log::Any if you choose ...


    The way forward always starts with a minimal test.

      Why do you like Log::Any for log production and Log::Dispatch for log consumption?

      Functionally, I can achieve the same thing with Log:::Log4perl appenders without have to use but one framework

      Please don't take my question and comment as being defensive or as an attack. I ask to understand. I agree that what you describe is technically correct.

        Because if I use Log::Any for production, I can use any adapter for consumption, meaning I can swap out or override easily. Also because most of the CPAN modules I like use Log::Any so I can control output from them in my own logging framework.

        Also note that I only gave Log::Dispatch as an example of an adapter, one that can multiplex. Normally you only need to load Log::Any and can use the default adapters that are provided with the companion Log::Any::Adapter.


        The way forward always starts with a minimal test.
Re: Wanted: Opinions on Logging Frameworks
by Ea (Chaplain) on Apr 17, 2018 at 20:36 UTC
    If you have the time to get to know the main differences between a few of the frameworks, maybe consider writing a review? Getting a side-by-side comparison between modules is very handy for making those decisions. I should be logging more, but the only one I've used is Mojo::Log, so I'd love to know what you find out.

    Sometimes I can think of 6 impossible LDAP attributes before breakfast.

    YAPC::Europe::2018 — Hmmm, need to talk to work about sending me.

Re: Wanted: Opinions on Logging Frameworks
by perlancar (Hermit) on Dec 20, 2018 at 11:23 UTC
Re: Wanted: Opinions on Logging Frameworks
by perlancar (Hermit) on Dec 20, 2018 at 14:55 UTC
    A correction: Log::Any was not created by Randal L. Schwartz (merlyn, MERLYN on CPAN) but by Jonathan Swartz (swartz, JSWARTZ on CPAN).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1212938]
Approved by NetWallah
Front-paged by NetWallah
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (9)
As of 2024-03-28 12:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found