New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[2.5.x] LoggerConfigurator requires an immutable map #6679
Comments
You can do a custom logger configurator in Java, although it's not pretty. Here's a compile time Java app: class LoggerConfigurator {
private final play.api.LoggerConfigurator delegate;
public LoggerConfigurator(play.api.LoggerConfigurator delegate) {
this.delegate = delegate;
}
public static Optional<LoggerConfigurator> fromClassLoader(ClassLoader classLoader) {
return OptionConverters.toJava(LoggerConfigurator$.MODULE$.apply(classLoader)).map(LoggerConfigurator::new);
}
public void configure(Environment env) {
delegate.configure(env.underlying());
}
} Example project: https://github.com/wsargent/play-java-compile-di If you can put together a PR that puts together the docs and tests, we can merge it for 2.6... |
It should work if I just do the configurator in Scala, right ? I'll do a pull for this |
@igmar You could write the Java API version in Scala, but typically we like to write Java APIs in Java so they're more readable to Java programmers. You do end up with weird quirks like the |
Clear |
I'm working on this one. Some things I ran into :
This is a Java Play 2.5.12 project, with the logging configurator in Scala.
Any advice ? |
Did some more digging :
play run blows up with the above stacktrace. Looking at the code that loads it :
it seems that is also contains the Logback logger configurator on the classpath, which the JVM seems to pick first. running in prod mode seems fine :
Which in this case, is expected behaviour (it's missing the right config files). It however does seem to pick the right configurator. |
Reference: #6045 |
Fixed via #7187 |
Creating a custom logger configurator in Java is pretty hard / impossible right now. LoggerConfigurator requires scala.collection.immutable.Map, which isn't easy in Java, also since the JavaConversions package only returns mutable maps.
I would be nice if a custom logger configurator can also be done from Java, and not requiring Scala.
In addition, following the directions as set on https://www.playframework.com/documentation/2.5.x/SettingsLogger#Using-a-Custom-Logging-Framework leads to ClassNotFound exceptions.
The text was updated successfully, but these errors were encountered: