Hi Scott / Play devs
I'm having the same trouble, and there's a workaround/fix.
(That is, logging works as configured, when I start Play 2 via the "run" command.
However when I start via the stage and dist builds, no log messages are printed.)
1. The workaround / fix
Comment out the call to Logger.configure, see below:
trait Server {
// First delete the default log file for a fresh start
...
/* PROD log level bugfix / workaround: comment out Logger.configure(...).
This call doesn't specify the "levels" parameter so all log levels are reset.
Also, this is not the first invokation of Logger.configure, but the 2nd!
Something is amiss ...
// Configure the logger for the first time
Logger.configure(
Map("application.home" -> applicationProvider.path.getAbsolutePath),
mode = mode)
*/
2. Debugging
I did some debugging, and it seems Play 2 first configures all loggers correctly (as specified in application.conf).
But then Play 2 configures them again (see above), and then all loggers seems to be reset to some default levels
(e.g. ERROR and INFO) so none of my log messages are displayed.
Here is where Play configures logging the first time:
====================================
object NettyServer {
...
def main(args: Array[String]) {
... createServer(applicationPath).getOrElse(System.exit(-1)) ...
}
--> calls -->
class StaticApplication ... {
val application = new Application(..., Mode.Prod)
...
}
--> calls -->
Application {
...
// Reconfigure logger
{
...
Logger.configure(
...
...
}
Here is where Play configures logging the second time:
====================================
/**
* provides generic server behaviour for Play applications
*/
trait Server {
// First delete the default log file for a fresh start
...
// Configure the logger for the first time
Logger.configure(
Map("application.home" -> applicationProvider.path.getAbsolutePath),
mode = mode)
3. No "levels" specified
The *first* call to Logger.configure looks like so:
Logger.configure(
Map("application.home" -> path.getAbsolutePath),
configuration.getConfig("logger").map { loggerConfig =>
loggerConfig.keys.map {
case "resource" | "file" | "url" => "" -> null
case key @ "root" => "ROOT" -> loggerConfig.getString(key, validValues).map(setLevel).get
case key => key -> loggerConfig.getString(key, validValues).map(setLevel).get
}.toMap
}.getOrElse(Map.empty),
mode)
This sets a certain "levels" parameter to these values: (for me)
Map(application -> TRACE, app.mailer -> TRACE, app.openid -> TRACE, play -> INFO, ROOT -> DEBUG)
The *second* time the configuration happens, "levels" is not specified (!), so the default value, Map(), is used, and log levels are reset to ERROR or INFO.
Logger.configure(
Map("application.home" -> applicationProvider.path.getAbsolutePath),
mode = mode)
4. A workaround
Perhaps the second invokation of Logger.configure() is broken?
The comment just above it, "// Configure the logger for the first time",
is incorrect, anyhow, since it's actually the 2nd call.
Best regards, KajMagnus