At the moment a default entry looks something like this:
Oct 12, 2008 9:45:18 AM myClassInfoHere
INFO: MyLogMessageHere
How do I get it to do this?
Oct 12, 2008 9:45:18 AM myClassInfoHere - INFO: MyLogMessageHere
Clarification I'm using java.util.logging
Per screenshot, in Eclipse select "run as" then "Run Configurations..." and add the answer from Trevor Robinson with double quotes instead of quotes. If you miss the double quotes you'll get "could not find or load main class" errors.
Similar to Tervor, But I like to change the property on runtime.
Note that this need to be set before the first SimpleFormatter is created - as was written in the comments.
if you're using java.util.logging, then there is a configuration file that is doing this to log contents (unless you're using programmatic configuration). So, your options are
1) run post -processor that removes the line breaks
2) change the log configuration AND remove the line breaks from it. Restart your application (server) and you should be good.
1)
-Djava.util.logging.SimpleFormatter.format
Java 7 supports a property with the
java.util.Formatter
format string syntax.See here.
My favorite is:
which makes output like:
2) Putting it to IDEs
IDEs typically let you set system properties for a project. E.g. in NetBeans, instead of adding -D...=... somewhere, add the property in the action dialog, in a form of
java.util.logging.SimpleFormatter.format=%1$tY-%1$tm-...
- without any quotes. The IDE should figure out.3) Putting that to Maven - Surefire
For your convenience, Here is how to put it to Surefire:
4) Hand-made
I have a library with few
java.util.logging
related classes. Amongst them, it'sSingleLineFormatter
. Downloadable jar here.