Which logging module?

acme on 2008-08-28T06:57:30

One of Perl's mottos is "there is more than one way to do it". This is of course a great thing, except when there are two ways to do it and I can't decide which is the better one or the most popular one. Such is it with logging modules - there are two stong candidates: Log::Dispatch and Log::Log4perl. Both do about the same thing, which makes it annoying to decide between the two. Which one do you use? Which one should become the best practice CPAN module for logging?


Naming

Smylers on 2008-08-28T11:34:34

I'd pick Log::Dispatch, to avoid promoting Log::Log4perl as being a good name for a Cpan module: repeating the top-level namespace obviously doesn't help with knowing what the module does ("When you said 'Log' the first time I wasn't sure whether this really is a logging module, but now you've said 'Log::Log' I can see that you mean it"?); and putting "4perl" at the end, that's to distinguish it from all those Cpan modules which aren't for use with Perl is it?

(Yes, I know why Log::Log4perl is called what it is; that still doesn't mean it should be encouraged.)

Re:Naming

Aristotle on 2008-08-29T12:17:07

It should have been called simply Log4perl.

How can we support both?

brian_d_foy on 2008-08-28T18:00:57

I've been thinking a lot about the same thing, and I'd really like to see something like an agnostic logging interface where users could use either as they liked, just as DBI does for databases.

I'd like to put in logging calls into my modules, but without a dependency on any logging module. If an application uses Log::Dispatch, my module level calls get converted into Log::Dispatch things. If they use Log4perl, then my module does the right thing for that. If they don't use either, there is a default null class sorta thing that handles the calls.

I have a private application which does this about half way. The application basically uses the same interface (trace, debug, warn, etc) methods, but it autoconfigures at the beginning. It's a big pile of crap because it's half done and my first idea on how to do it, but someone probably has a good idea.

However it works out, I think both packages are nice and I don't want to make other people choose. I like Log4perl, but that's just because it does what I want and I don't need to do any more.

Re:How can we support both?

Dom2 on 2008-08-28T18:58:42

I'd really like to see something like an agnostic logging interface where users could use either as they liked, just as DBI does for databases.

Be careful what you wish for. I've been doing lots of Java recently and exposed to the pain of commons-logging. I wouldn't want to see that repeated…

I use Log::Dispatch

Ron Savage on 2008-08-29T00:36:11

It's well-designed, and works perfectly.

Log::Log4Perl looks big, complex, although it may load components intelligently, and hence, dare I say it, has all the hall-marks of the disaster known as Cobol-for-Dummies, previously known as Java.

unix vs win32 logging

ddick on 2008-08-29T03:45:04

I take it that we're talking about best practice for unix style logging modules?

Re:unix vs win32 logging

acme on 2008-08-29T06:43:29

Perl runs fine on win32. When running an application, you want all the the logs in one place. Using one of these modules it should be possible for all the applications in your module to log in a consistent place (even if they are written by other people), be that a file, syslog, or whatever.

both

pfig on 2008-08-29T09:36:07

log::log4perl to set up the infrastructure and different log::dispatch loggers attached to the different logging classes and/or levels.