Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
542 views
in Technique[技术] by (71.8m points)

java.util.logging: how to suppress date line

I'm trying to suppress output of the date line durinng logging when using the default logger in java.util.logging. For example, here is a typical output:

Jun 1, 2010 10:18:12 AM gamma.utility.application info

INFO: ping: db-time=2010-06-01 10:18:12.0, local-time=20100601t101812, duration=180000
Jun 1, 2010 10:21:12 AM gamma.utility.application info
INFO: ping: db-time=2010-06-01 10:21:12.0, local-time=20100601t102112, duration=180000

I would like to get rid of the Jun 1, 2010... lines, they just clutter my log output. How can I do this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

From Java SE 7 there is a new system property: java.util.logging.SimpleFormatter.format.

The same property is also configurable on the java.util.logging properties file (logging.properties). If you are an Eclipse user, and you are annoyed by the double line message in the console output, you could change the jre logging.properties file (JDK_HOME/jre/lib/logging.properties) in this way:

java.util.logging.SimpleFormatter.format=%4$s: %5$s [%1$tc]%n

Some example format is available here: http://docs.oracle.com/javase/7/docs/api/index.html?java/util/logging/SimpleFormatter.html.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...