Playspec not picking logger configuration

32 Views Asked by At

In my play application, I have provided a logback.xml. The configuration for controller AnswerController is <logger name="controllers.AnswerController" level="TRACE" additivity="false"> <appender-ref ref="STDOUT"/> </logger>

But when I run my test case, I don't see any logs. Do I need to configure logback explicitly? I am using custom application loader.

Why are the logs now showing?

1

There are 1 best solutions below

0
Manu Chadha On

I added the LoggerConfigurator to my code and it seem to work (still early day to confirm if this will create some side effect. Though I don't the flow of why this makes things work (BTW, I do the same for my customer application loader as well)

class AnswerControllerUnitSpec extends PlaySpec with BeforeAndAfterAll with BeforeAndAfterEach with OneAppPerSuiteWithComponents{


  override def beforeEach() = {
    println("------------new test -----------------")
  }

  LoggerConfigurator(context.environment.classLoader).foreach {
    _.configure(context.environment, context.initialConfiguration, Map.empty)
  }
...
}