Package org.apache.juli
Class OneLineFormatter
- java.lang.Object
-
- java.util.logging.Formatter
-
- org.apache.juli.OneLineFormatter
-
- Direct Known Subclasses:
JsonFormatter
public class OneLineFormatter extends java.util.logging.FormatterProvides same information as default log format but on a single line to make it easier to grep the logs. The only exception is stacktraces which are always preceded by whitespace to make it simple to skip them.
-
-
Constructor Summary
Constructors Constructor Description OneLineFormatter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddTimestamp(java.lang.StringBuilder buf, long timestamp)java.lang.Stringformat(java.util.logging.LogRecord record)protected static java.lang.StringgetThreadName(int logRecordThreadId)LogRecord has threadID but no thread name.java.lang.StringgetTimeFormat()Obtain the format currently being used for time stamps in log messages.protected java.lang.StringresolveThreadName(java.util.logging.LogRecord record)voidsetTimeFormat(java.lang.String timeFormat)Specify the time format to use for time stamps in log messages.
-
-
-
Method Detail
-
setTimeFormat
public void setTimeFormat(java.lang.String timeFormat)
Specify the time format to use for time stamps in log messages.- Parameters:
timeFormat- The format to use using theSimpleDateFormatsyntax
-
getTimeFormat
public java.lang.String getTimeFormat()
Obtain the format currently being used for time stamps in log messages.- Returns:
- The current format in
SimpleDateFormatsyntax
-
format
public java.lang.String format(java.util.logging.LogRecord record)
- Specified by:
formatin classjava.util.logging.Formatter
-
resolveThreadName
protected java.lang.String resolveThreadName(java.util.logging.LogRecord record)
-
addTimestamp
protected void addTimestamp(java.lang.StringBuilder buf, long timestamp)
-
getThreadName
protected static java.lang.String getThreadName(int logRecordThreadId)
LogRecord has threadID but no thread name. LogRecord uses an int for thread ID but thread IDs are longs. If the real thread ID > (Integer.MAXVALUE / 2) LogRecord uses it's own ID in an effort to avoid clashes due to overflow.Words fail me to describe what I think of the design decision to use an int in LogRecord for a long value and the resulting mess that follows.
- Parameters:
logRecordThreadId- the thread id- Returns:
- the thread name
-
-