Peter Staab Peter Staab -5 years ago 244
Perl Question

How can I set the log format in Dancer2?

I am trying to change the logging format to include the line number of the file for a Dancer2 app. The default does not seem to do this. If I add the line

log_format: "[%f--%l] %m"

(which seems correct based on the Dancer2::Core::Role::Logger documentation) nothing changes.

Answer Source

log_format isn't a global configuration directive. It's specific to the particular logging engine you're using, so you have to put it in the configuration section for that engine.

For example, if you're using the Dancer2::Logger::File engine:

logger: "File"

      log_format: "[%f--%l] %m"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download