Please, take a look at this example:
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Test {
public static void main(String[] args) {
Logger log = LoggerFactory.getLogger(Test.class);
log.info("Hello World");
}
}
The program generates following output:
2011-11-01 13:06:05 Test main
INFO: Hello World
How to get rid of the first line? How to set Logger not to show methods invocations?
slf4j uses jdk14 in my application. In addition, I have two handlers, so it would be nice if there would be a way to disable methods invocations logging just for one handler.
The two lines are both generated by the call to
log.info. It seems the logger implementation default format generates line breaks. In no way “method entry” itself produces any output.To make it clear: If you log twice as in
I expect this output:
Oh, and the general way to setup Java-Util-Logging for your JDK is described here:
http://download.oracle.com/javase/1.4.2/docs/guide/util/logging/overview.html
You will have to look out the “Formatters” section and implement your own formatter (AFAIK). Or simply use a usable logging implementation behind slf4j like logback or log4j.