Skip Menu |

This queue is for tickets about the App-Daemon CPAN distribution.

Report information
The Basics
Id: 89632
Status: resolved
Priority: 0/
Queue: App-Daemon

People
Owner: Nobody in particular
Requestors: g_ml2000-x [...] yahoo.de
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: App::Daemon should use a separate logger
It would be nice if App::Daemon would use a separate logger and Log4perl configuration: Most of the time, if somebody sets the log threshold to debug or trace, the intention is probably to debug some user-written code. Currently it requires some efforts in such a case to avoid filling the logs with debug output from the App::Daemon library code ... Regards, Peter
On Sun Oct 20 07:34:48 2013, g_ml200 wrote: Show quoted text
> It would be nice if App::Daemon would use a separate logger and > Log4perl configuration
Actually, App::Daemon just uses the local logger, so unless you Log4perl configuration enables debug logs across the board, you shouldn't see any messages from the App::Daemon library code. If you enable the root logger, however, you'll see them, that's how it's designed. There can only be one Log4perl configuration per process by definition.
From: g_ml2000-x [...] yahoo.de
... what do you mean by "local logger"? App::Daemon uses Log4perl's "Easy Mode", which uses the root logger. I personally (but I assume, this is pretty much standard), usually don't need different logging configurations for different code parts, so unless there are any special requirements, I also just use the root logger in my own code, which is configured to produce a verbose local file for debugging (primarily my own program code;) and forward everything more severe to syslog. Unfortunately this means that with a log level of debug or below, I also get all the debug messages from App::Daemon in my log file. I'm no Log4(j|perl) expert, but as far as I can see, avoiding this would mean to never use "easy" mode or the root logger in my own code (Actually, currently my workaround usually is to 's/DEBUG/TRACE/' in App::Daemon's code, which doesn't scale to well). Wouldn't it be possible (and a better solution) to change App::Daemon to do something like "get_logger('App::Daemon')->debug(...)" instead of just "DEBUG(...)"? This way, it should work to use a low global threshold for debugging and be able to set a separate log level for App::Daemon ...
On Wed Oct 23 05:11:23 2013, g_ml200 wrote: Show quoted text
> Wouldn't it be possible (and a better solution) to change App::Daemon > to do something like "get_logger('App::Daemon')->debug(...)" instead > of just "DEBUG(...)"?
Actually, that's exactly what DEBUG() does. I suspect you're getting the App::Daemon messages in your logs because you've defined the root logger in your Log4perl configuration to forward its messages to a file (and the root logger gets messages bubbling up from the other loggers). What you want to do instead is forward your application's logger's messages to a file.
From: g_ml2000-x [...] yahoo.de
MSCHILLI wrote: Show quoted text
> Actually, that's exactly what DEBUG() does.
Aaaah ;-) I saw the log statements in App::Daemon and read about "Easy Mode's" single root logger in the Log::Log4perl documentation, so I assumed DEBUG() to be just a shorter way of saying "Log::Log4perl->get_logger("")->debug(...)". Thanks for the clarification! As it turns out, my Problem can simply be solved by adding log4perl.logger.App.Daemon=ERROR to the Log4perl configuration. Maybe the documentation (both, App::Daemon and Log4perl) could be clarified a little? At least to me introducing "Easy Mode" for "teaching purposes" sounds like this shouldn't be used for "real" applications and from the App::Daemon documentation, I could not see any obvious way, how to control App::Daemon's logging separately from the rest of the program. The good news is: Things are actually easier, than the documentation suggests ;-) Thanks, Peter
On Sun Oct 27 06:18:59 2013, g_ml200 wrote: Show quoted text
> As it turns out, my Problem can simply be solved by adding > log4perl.logger.App.Daemon=ERROR > to the Log4perl configuration.
You can either choose what you want to disable (like you did above with App::Daemon) or what you want to explictely enable (like your application My::App). Both are valid use cases, but serve different needs. I've added some documentation to hopefully clarify the issue: https://github.com/mschilli/app-daemon/commit/6695b644c2e70fe03fc6c641298a8d18157ada38