I'm converting an existing Dancer2 app to use Log4perl. In my Dancer2 app's config.yml, I have the following:
logger: log4perl
engines:
logger:
log4perl:
config_file: log4perl.conf
And log4perl.conf is as follows:
log4perl.rootLogger = INFO, LOG1
log4perl.appender.LOG1 = Log::Log4perl::Appender::File
log4perl.appender.LOG1.filename = app_name.log
log4perl.appender.LOG1.mode = append
log4perl.appender.LOG1.layout = Log::Log4perl::Layout::PatternLayout
log4perl.appender.LOG1.layout.ConversionPattern = %d %p %m %n
(This is very similar to the example given in Dancer2::Logger::Log4perl's POD.)
When I run the app via plackup
or use
the module in test scripts, it reports loading my configuration (and will throw errors if I have anything invalid in config.yml, but I'm not sure it's using log4perl at all, or ever reading log4perl.conf (no error is reported, even if I move log4perl.conf away entirely). app_name.log is never created, and all of my app's log messages are sent to the console as if I had no logging configuration at all. There are no errors or warnings; the app just loads and ignores my logger config.
I have double checked all relevant modules are installed (though I would hope something would throw a warning otherwise), including Dancer2::Logger::Log4perl, Log::Log4perl and all of the Appender and Layout modules shown above. Running on Perl 5.40.0.
I've also started a new Dancer2 app from scratch with the same logger config, with the same result, so it's not some leftover cruft from elsewhere in my larger application.
What am I doing wrong?