Is it possible to set the log level globally for Log4perl by passing a command line flag or setting an environment variable (and not changing the original logging setup)? The documentation and FAQ don't seem to mention any way to do this.
Asked
Active
Viewed 613 times
2 Answers
0
You may use somthing like this:
Log::Log4perl->get_logger()->level(
Log::Log4perl::Level::to_priority($ENV{APP_LOG_LEVEL})
);
and run script:
APP_LOG_LEVEL=DEBUG perl app.pl

Denis Ibaev
- 2,470
- 23
- 29
0
If you use the configuration file syntax to define your appenders (note that you don't have to place this into a real file; you can also have the configuration definition inside your program), you already have environment variable substitution out of the box. See the section named "Variable Substitution" in the Log4Perl documentation.

user1934428
- 19,864
- 7
- 42
- 87
-
I specifically don't want to change the original logging setup, to avoid complicating the code base. – l0b0 Oct 30 '17 at 19:19