Been struggling to get any logging output in unit tests in Play 2.3 using Logger.error("an error")
. I've tried all of these examples which seem to be outdated.
The closest I got was with a build.sbt
containing the following:
testOptions in Test += Tests.Argument("-Dlogger.resource=conf/test-logger.xml")
This causes the test-logger.xml
file to configure the logger, but still I do not get output from any tests.
Has anyone had any success with this in Play 2.3?
Temporary Workaround
I'm currently using a quick util class to deal with this until it is fixed. Added here as it may be useful for someone else.
public class Logger {
public static void debug(String message) {
System.out.println(String.format("[debug] %s", message));
}
public static void info(String message) {
System.out.println(String.format("[info] %s", message));
}
public static void warn(String message) {
System.out.println(String.format("[warn] %s", message));
}
public static void error(String message) {
System.err.println(String.format("[error] %s", message));
}
}