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

Hello Monks,

Does anyone have any opinions (recommendation) regarding a logger for Perl. I've investigated the following:

Log::Agent::Logger Log::ErrLogger Log::Logger
and was wondering if anyone had a favorite (and why)?

It would be nice to write to STDOUT and at the same time log the message to a file with additional time-stamp information. Also, it would be nice to take STDERR when using "or die" in the code and write that to the file as well.

Thanks,
Jay

Replies are listed 'Best First'.
Re: Writing to a Logfile from a Perl Console Application.
by bluto (Curate) on Jul 11, 2002 at 19:22 UTC
    Check out Log::Dispatch. It will log to multiple destinations (screen, file, mail, syslog, etc.) and has various severity levels ala syslog (i.e. warnings, errors, debug, etc.). It is easy to provide you own format for each destination.

    One way I have warn and die (and their ilk) log through this is just to provide my own __WARN__ and __DIE__ "signal handlers" and then call the appropriate logging method from within them. This is kludegy, but it tends to work ok.

    bluto

      Thanks so much,

      I'm particulary fond of the "-callbacks" feature. It let's me customize the output based on the channel.

      Cheers!