Details
Description
GeoTools uses Java logging (java.util.logging package), but GeoServer need the ability to log to different frameworks. We wish (if possible) to code against Java logging API since commons-logging is not the only candidate (SLF4J is an other one), Java logging is an attempt of standard API available on every JVM (1.4+) and its API is more elaborated than commons-logging one. The proposal is:
- Create a java.util.logging.Logger subclass, CommonLogger, that delegates everything to commons-logging, including methods like info(String) and isLoggable(Level). Some methods may not have direct match (e.g. getHandler), but they are of interest only for advanced users (and an indirect match is possible anyway with the CommonHandler already available in the GeoTools code base).
- Switch all Logger.getLogger(xxx) methods to a special GeoTools utility class (maybe the existing Logging class) that will return either the plain java logging logger, or the CommonLogger, depending on a configuration.
- We'll have some way to switch GeoTools logging one way or the other (and the same will have to work for GeoServer as well).
The level matching currently used is:
| Log4J Level | java.util.logging Level |
|---|---|
| ALL | FINEST |
| TRACE | FINER |
| DEBUG | FINE/CONFIG |
| INFO | INFO |
| WARN/ERROR | WARNING |
| FATAL | SEVERE |
| OFF | OFF |
CommonLogger pseudo-code:
class CommonLogger extends Logger { private Log commonLog; public boolean isLoggable(Level level) { switch (level) { case FINER: return commonLog.isTraceEnabled(); case FINE: return commonLog.isDebugEnabled(); // etc... } } public void finer(String message) { commonLog.trace(message); } // etc... }
Issue Links
- is depended upon by
-
GEOS-1505
Switch logging subsystem to the new GeoTools Logging.getLogger(xxx) call
-
-
GEOS-1021
Pipe all geoserver/geotools logging into commons-logging in geoserver
-
- is related to
-
GEOS-1502
Explain logging level settings and make sure there is mention in the release notes
-
-
GEOT-1202
CommonHandler issues
-
-
GEOT-1598
LoggerAdapter performs expensive operations before checking for the logging level
-
-
GEOT-1220
Let the 'Logging' class be more useful to geotools library client code
-
I noticed that my favourite (log5j) has recently renamed itself:
- http://www.slf4j.org/ Simple Logging Facade for Java
Just adding the comment here so others can shoot down log4j as the answer.