Logging Sensor
Logging Frameworks to be addressed
- Log4J
- java.util.logging
- Apache Commons Logging
- Logback (basically always used through SLF4J)
Facades
Mostly logging is not used directly but often used through a facade like SLF4J. In fact most tutorials on logback state that it has be used with SLF4J
Instrumentation
We need a method/methods that provide the following:
- read the log level
- read the log message
- operate on as little methods as possible
Framework | Instrumentation point | |
---|---|---|
log4J | log4j offers a nice central point where loggings of all levels are handled. This method is org.apache.log4j.Category.forcedLog | |
java.util.logging | ||
Apache Commons Logging | ||
Logback | Actuall instrumenting logback classic directly is not too nice. The class handling the logging is https://github.com/qos-ch/logback/blob/master/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java which provides different internal logging methods for each level. There is no central place where the logging is handled independently of the loglevel. We would have to instrument a bunch of methods. | |
SLF4J | http://grepcode.com/file/repo1.maven.org/maven2/org.slf4j/slf4j-api/1.7.12/org/slf4j/Logger.java#Logger is an interface uses the http://grepcode.com/file/repo1.maven.org/maven2/org.slf4j/slf4j-api/1.7.12/org/slf4j/LoggerFactory.java#LoggerFactory.getILoggerFactory%28%29 to find a LoggingFactory to create a Logger. So in fact we just need to have a look at the concrete adaptors for the technologies: |