google / flogger

A Fluent Logging API for Java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using environment variable to specify backend is too restrictive (ex: use inside application server or junit)

gaelbillard opened this issue · comments

Using -Dflogger.backend_factory=com.google.common.flogger.backend.slf4j.Slf4jBackendFactory#getInstance (for exemaple) to specify the backend to use is not usable for application running on same JVM with others like it is for tomcat or any application server. Even if it might be possible if one has control of the server, it will impact all application and could be problematic.
Could be imagine using a config file using a pre-defined name that would contains configuration that would be checked before looking at environment variable ?

This is a good point. For now I would suggest seeing if you can swap out the Platform class. DefaultPlatform is, well, a default and you can easily create an alternate Platform implementation which reads files for configuration instead of using system properties.

Of course you still have to specify that Platform with a system property, but it can then have a different instance per container and load different configurations.

I came here to open an issue about exactly the same topic. Without any other way to specify logging backend, Flogger locks out a variety of common implementation patterns or introduces unreasonable hurdles (for example, there is no path to using Flogger in a project you want to test with JUnit while still supporting importing it in Eclipse).

@gaelbillard, I would ask you to change the issues title, as it unnecessarily narrows the scope of the issue to application servers, whereas the actual issue is more wide reaching and of interest to more people than just that exact scenario.

👍