Reputation: 9520
I'm using log4perl with a set of scripts and objects. I'd like to be able to switch between different logging configurations according command line or environment parameters, e.g. in 'verbose' mode, print out all messages from INFO level upwards, a 'debug' mode that sends DEBUG messages to STDERR and other messages to STDOUT, and a silent mode that suppresses all output except FATAL messages.
What is the best way to do this? Should I have several logger config files and load the appropriate file depending on the mode that the script is to run in? If I understand the docs correctly, I want to be altering the verbosity and threshold of the root logger so that all loggers attached to objects (i.e. loggers with categories) will obey the same rules as the root logger.
Upvotes: 1
Views: 237
Reputation: 39158
Yes, have several configurations to choose from. Use Log::Log4perl::CommandLine for the command-line integration.
Upvotes: 3