|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.logging.Formatter com.sun.grid.jgdi.util.SGEFormatter
public class SGEFormatter
This Formater formats LogRecords into one line. What columns and
delimiters are formated can be configured.
The default format is
<date>|<host>|<source method>|<level>|
<message>
If the withStacktrace flag is set, the stacktrace of a logged excpetion is also included.
Logger logger = Logger.getLogger("test logger"); ConsoleHandler consoleHandler = new ConsoleHandler(); SGEFormatter formatter = new SGEFormatter("test formatter"); int columns [] = { SGEFormatter.COL_LEVEL_LONG, SGEFormatter.COL_MESSAGE }; formatter.setColumns(columns); formatter.setDelimiter(":"); consoleHandler.setFormatter(formatter); logger.addHandler(consoleHandler); logger.setUseParentHandlers(false);This example will create log entries with the following format:
<log level>:<message>
Nested Class Summary | |
---|---|
static class |
SGEFormatter.Column
|
Field Summary | |
---|---|
static int |
COL_HOST
This column contains the hostname. |
static int |
COL_LEVEL
This column contains the log level of the log record in a short form (S, I, D). |
static int |
COL_LEVEL_LONG
This columns contains the log level of the log record in it's log form. |
static int |
COL_MESSAGE
This column the log message. |
static int |
COL_NAME
This columns contains the name of the SGEFormatter. |
static int |
COL_SOURCE
This column contains the source class and source method name which produces the log message. |
static int |
COL_THREAD
This column contains the thread ID of the log record. |
static int |
COL_TIME
This column contains the timestamp of the log record. |
static int[] |
DEFAULT_COLUMNS
The default columns are COL_TIME , COL_HOST , COL_SOURCE ,
COL_LEVEL , COL_MESSAGE . |
Constructor Summary | |
---|---|
SGEFormatter()
|
|
SGEFormatter(java.lang.String aName)
Create a new SGEFormatter . |
|
SGEFormatter(java.lang.String aName,
boolean withStackTrace)
Create a new SGEFormatter . |
|
SGEFormatter(java.lang.String aName,
boolean withStackTrace,
int[] aColumns)
Create a new SGEFormatter . |
Method Summary | |
---|---|
java.lang.String |
format(java.util.logging.LogRecord record)
format a log Record. |
static SGEFormatter.Column |
getColumn(java.lang.String name)
|
boolean |
getWithStackTrace()
get the withStackTrace flag. |
void |
setColumns(int[] aColumns)
set the columns for the formatter. |
void |
setDelimiter(java.lang.String aDelimiter)
set the delimiter. |
void |
setWithStackTrace(boolean withStackTrace)
set the withStackTrace flag. |
Methods inherited from class java.util.logging.Formatter |
---|
formatMessage, getHead, getTail |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int COL_TIME
public static final int COL_HOST
public static final int COL_NAME
public static final int COL_THREAD
public static final int COL_LEVEL
public static final int COL_MESSAGE
public static final int COL_SOURCE
public static final int COL_LEVEL_LONG
Level.toString()
,
Constant Field Valuespublic static final int[] DEFAULT_COLUMNS
COL_TIME
, COL_HOST
, COL_SOURCE
,
COL_LEVEL
, COL_MESSAGE
.
Constructor Detail |
---|
public SGEFormatter(java.lang.String aName)
SGEFormatter
.
aName
- name of the formatterpublic SGEFormatter(java.lang.String aName, boolean withStackTrace)
SGEFormatter
.
aName
- name of the formatterwithStackTrace
- include the stacktracepublic SGEFormatter(java.lang.String aName, boolean withStackTrace, int[] aColumns)
SGEFormatter
.
aName
- name of the formatterwithStackTrace
- include the stacktraceaColumns
- visible columnspublic SGEFormatter()
Method Detail |
---|
public static SGEFormatter.Column getColumn(java.lang.String name)
public final void setDelimiter(java.lang.String aDelimiter)
aDelimiter
- the new delimiterpublic final void setColumns(int[] aColumns)
aColumns
- the columnspublic final void setWithStackTrace(boolean withStackTrace)
withStackTrace
flag.
withStackTrace
- the new value of the flagpublic final boolean getWithStackTrace()
withStackTrace
flag.
withStackTrace
flagpublic final java.lang.String format(java.util.logging.LogRecord record)
Attention: This method is not thread safe
format
in class java.util.logging.Formatter
Formatter.format(java.util.logging.LogRecord)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |