public class SGEFormatter
extends java.util.logging.Formatter
<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>
| Modifier and Type | Class and Description |
|---|---|
static class |
SGEFormatter.Column |
| Modifier and Type | Field and Description |
|---|---|
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 and Description |
|---|
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. |
| Modifier and Type | Method and Description |
|---|---|
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. |
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.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()
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.FormatterFormatter.format(java.util.logging.LogRecord)Copyright © 2007 Sun Microsystems, Inc. All rights reserved.