Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Dependency to Log::Log4perl

by Dirk80 (Pilgrim)
on Feb 03, 2020 at 08:50 UTC ( [id://11112311]=perlquestion: print w/replies, xml ) Need Help??

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

Currently I'm using no logger in my modules. I just use die, warn, croak and carp. I want to change that. After a short investigation I saw that Log::Log4perl is the logger I want to use. But now I'm not sure if I should use it directly or not. Or in other words. If my modules should have a dependency on it.

I've seen the following message from cpan:

Loading internal logger. Log::Log4perl recommended for better logging

So cpan has an internal logger. And if Log::Log4perl is available then this logger is used. So there is no hard dependency.

What is your opinion? Should I also use an internal logger, e.g. My::Log and only use Log::Log4perl if it is available?

I would like to do that this way. I don't want to invent things which are already there. So another question. Is there already an implementation of an internal logger (is it a wrapper class around Log::Log4perl?) ?

Thanks for your help!

Replies are listed 'Best First'.
Re: Dependency to Log::Log4perl
by salva (Canon) on Feb 03, 2020 at 09:00 UTC
    Take a look at Log::Any!

    If you are planning to release your modules in CPAN, IMO, depending on something like Log::Log4perl is not a good idea, as you will be forcing that logging framework into your module users, and not everybody likes it!

      Thank you very much. Cool. I'll try it. Looks exactly for what I've been looking for.

Re: Dependency to Log::Log4perl
by Corion (Patriarch) on Feb 03, 2020 at 08:54 UTC

    Using your own logger class IMO only makes sense if you're planning to distribute your own logger with the module/application itself.

    Otherwise, if you're adding a dependency anyway, use Log::Log4perl, as it is at least a common dependency.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2024-04-24 14:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found