in reply to Re^2: WWW::Mechanize::Chrome : random complaining that Log4perl is not initialised and test fails
in thread WWW::Mechanize::Chrome : random complaining that Log4perl is not initialised and test fails

To me, Log::Log4perl requires a lot of configuration to set up properly and I feel it could do with more convenient ways to switch log-producing locations on and off.

On the other hand, Log::Log4perl can be configured to separate out different logging messages and different logging sources into different output streams, so it's not all bad if you have a larger application of which WWW::Mechanize::Chrome is just a part.

  • Comment on Re^3: WWW::Mechanize::Chrome : random complaining that Log4perl is not initialised and test fails

Replies are listed 'Best First'.
Re^4: WWW::Mechanize::Chrome : random complaining that Log4perl is not initialised and test fails
by talexb (Chancellor) on Aug 12, 2025 at 13:55 UTC

    Huh. I've used Log::Log4perl at one client since 2018, and it's worked very well. Sure, turning logging up or down does require me to edit a file, but that's fine. I usually send INFO messages to the screen, but send DEBUG messages to the log, and ERROR messages go by E-Mail. I started to work on also getting ERRORs sent to Slack, but got busy with other stuff.

    The module also takes care of rotating the log files (size, number of backups to keep), which is super handy. I haven't tried any other logging modules because Log4perl does everything I need and Just Works.

    Alex / talexb / Toronto

    As of June 2025, Groklaw is back! This site was a really valuable resource in the now ancient fight between SCO and Linux. As it turned out, SCO was all hat and no cattle.Thanks to PJ for all her work, we owe her so much. RIP -- 2003 to 2013.

      Yes, the configurable options are great.

      I think the main thing I'm missing, especially with WWW::Mechanize::Chrome logging, is a good structured log viewer, that lets me fold/unfold log messages and displays JSON (or Dumper output or whatever) in a structured view.

      But down that road lies the madness that is Kibana and Elasticsearch.

          .. a good structured log viewer, that lets me fold/unfold log messages and displays JSON (or Dumper output or whatever) in a structured view.

        I suppose you could fold/unfold lines like hiding DEBUG level messages but display everything else, but only keep the full file around for a while. After a day or two, perhaps filter the log file to delete the DEBUG information, and keep the reduced files around a little longer.

        Every situation is different, though, and it depends on how much space you have for log files, what detail level you want to keep, how far back you want logs for, and whether there's PII in the log files.

        Alex / talexb / Toronto

        As of June 2025, Groklaw is back! This site was a really valuable resource in the now ancient fight between SCO and Linux. As it turned out, SCO was all hat and no cattle.Thanks to PJ for all her work, we owe her so much. RIP -- 2003 to 2013.

      Sure, turning logging up or down does require me to edit a file, but that's fine.

      You're missing out, then :-)

      My Log::Any::Adapter::Daemontools has an option to adjust the log level in response to SIGUSR1 and SIGUSR2

      My yet-unreleased-to-cpan Plack::Middleware::DynamicDebug adjusts the Log::Any log level per-request depending on a magic cookie, so if something is going wrong in production I can visit the (password-protected) page that issues the cookie, configure a different log level, and then get full trace debugging written to the production service logs for only requests from my browser. It also adjusts the logging of Catalyst, DBIC, and turns on Carp::Always, but the sort of deep integration with the app is why I've never gotten around to making it a general CPAN module.

      Is there really no way to adjust Log4perl's log-levels on the fly?