I keep seeing tutorials and explanations, all based on the standard javadoc.
java.util.logging.SimpleFormatter.format="%1$tc %2$s%n%4$s: %5$s%6$s%n"
This prints 2 lines where the first line includes the timestamp (1$) and the source (2$); the second line includes the log level (4$) and the log message (5$)
So I guess that if (for whatever reason) I want to put the message before everything else, I just put
5$ at the beginning.
Where can I find a detailed explanation of what each of those numbered fields mean?
The JavaDocs you linked will show it as the function args, but if you ignore the first one the rest line up in place:
- date – a Date object representing event time of the log record.
- source – a string representing the caller, if available; otherwise, the logger’s name.
- logger – the logger’s name.
- level – the log level.
- message – the formatted log message returned from the Formatter.formatMessage(LogRecord) method. It uses java.text formatting and does not use the java.util.Formatter format argument.
- thrown – a string representing the throwable associated with the log record and its backtrace beginning with a newline character, if any; otherwise, an empty string.
For example, with the format you had:
%1$tc %2$s%n%4$s: %5$s%6$s%n
It would be the timestamp, source, a newline, the log level, the log message, then the backtrace