playframework / playframework

The Community Maintained High Velocity Web Framework For Java and Scala.
http://www.playframework.com
Apache License 2.0
12.56k stars 4.1k forks source link

Server.withRouter shuts down logging after run #6198

Open wsargent opened 8 years ago

wsargent commented 8 years ago

Play Version (2.5.x / etc)

2.5.x

API (Scala / Java / Neither / Both)

Scala

Actual Behavior

From https://groups.google.com/d/topic/play-framework/daAbQ3nHfjc/discussion

Documentation suggests using Server.withRouter() to test web service clients.

https://www.playframework.com/documentation/2.5.1/ScalaTestingWebServiceClients

This has unintended consequence of shutting down logging after the test. Subsequent logs do not appear on the console.

https://github.com/playframework/playframework/blob/440be28c9598d4ff0957cda1367803f95f4c50a0/framework/src/play-server/src/main/scala/play/core/server/Server.scala#L71-L75

I have minimal repo that demonstrates the issue here

https://github.com/jsw/play-2.5-logging-test

There is a work around by using a LoggerConfigurator that does nothing on shutdown:

https://gist.github.com/thetristan/dba8c5f6699c9d18b146e8c10d81a6f1

dgohlke commented 7 years ago

Thanks @wsargent & github user thetristan for the work-around. I put the two files from here into my test/resources directory and now all tests produce proper logging.