Reputation: 2577
Here is my code-
Logger log = Logger.getLogger("myApp");
log.info("hola");
it displays output as-
Mar 16, 2012 8:58:39 PM *packageName* main
INFO: hola
I don't want it to create a newline before "INFO" ... how do I tell logger to do it? I want my output to be like this-
Mar 16, 2012 8:58:39 PM *packageName* main INFO: hola
Much like syslog format.
Upvotes: 5
Views: 4952
Reputation: 13374
Have a look at how to configure the Java logging, and the documentation on how to specify formatting for SimpleFormatter
.
Upvotes: 0
Reputation: 7716
Various ways but here is one. Modify as necessary inside publish().
Logger log = Logger.getLogger("");
for (Handler handler :log.getHandlers() ) log.removeHandler(handler);
log = Logger.getLogger("myLogger");
log.addHandler(new Handler(){
public void publish(LogRecord record) {
System.out.println(record.getMessage());
}
public void flush() {
}
public void close() throws SecurityException {
}});
log.info("hola");
Upvotes: 1