|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.util.logging.Formatter
org.geotools.util.MonolineFormatter
A formatter writting log messages on a single line. This formatter is used by
Geotools 2 instead of SimpleFormatter. The main difference is that
this formatter use only one line per message instead of two. For example, a
message formatted by looks like:
By default, display only the level and the message. Additional fields can be formatted ifFINE core - A log message logged with level FINE from the "org.geotools.core" logger.
setTimeFormat(java.lang.String) or
setSourceFormat(java.lang.String) methods are invoked with a non-null argument. The
format can also be set from the
file. For example, user can cut and paste the following properties into
:
If the is wanted for the whole system (not just the packages) with level FINE (for example), then the following properties can be defined as below:############################################################ # Properties for the Geotools's MonolineFormatter. # By default, the monoline formatter display only the level # and the message. Additional fields can be specified here: # # time: If set, writes the time ellapsed since the initialization. # The argument specifies the output pattern. For example, the # pattern HH:mm:ss.SSSS display the hours, minutes, seconds # and milliseconds. # # source: If set, writes the source logger or the source class name. # The argument specifies the type of source to display. Valid # values are none, logger:short, logger:long, class:short and # class:long. ############################################################ org.geotools.util.MonolineFormatter.time = HH:mm:ss.SSS org.geotools.util.MonolineFormatter.source = class:short
java.util.logging.ConsoleHandler.formatter = org.geotools.util.MonolineFormatter java.util.logging.ConsoleHandler.encoding = Cp850 java.util.logging.ConsoleHandler.level = FINE
| Constructor Summary | |
MonolineFormatter()
Construct a default . |
|
MonolineFormatter(java.lang.String base)
Construct a . |
|
| Method Summary | |
java.lang.String |
format(java.util.logging.LogRecord record)
Format the given log record and return the formatted string. |
java.lang.String |
getSourceFormat()
Returns the format for displaying the source. |
java.lang.String |
getTimeFormat()
Returns the format for displaying ellapsed time. |
static MonolineFormatter |
init(java.lang.String base)
Setup a for the specified logger and its children. |
static MonolineFormatter |
init(java.lang.String base,
java.util.logging.Level level)
Convenience method setting both a and the logger levels. |
static void |
initGeotools()
Initialise the formatter for the "" loggers. |
static void |
initGeotools(java.util.logging.Level level)
Initialise the formatter for the "" loggers with the specified level. |
void |
setSourceFormat(java.lang.String format)
Set the format for displaying the source. |
void |
setTimeFormat(java.lang.String pattern)
Set the format for displaying ellapsed time. |
| 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 |
| Constructor Detail |
public MonolineFormatter()
public MonolineFormatter(java.lang.String base)
base - The base logger name. This is used for shortening the logger
name when formatting message. For example, if the base
logger name is "org.geotools" and a log record come from
the "org.geotools.core" logger, it will be formatted as
"[LEVEL core]" (i.e. the "org.geotools" part is ommited).| Method Detail |
public void setTimeFormat(java.lang.String pattern)
SimpleDateFormat. For example, the
pattern "HH:mm:ss.SSS" will display the ellapsed time
in hours, minutes, seconds and milliseconds.
pattern - The time patter, or to disable time formatting.public java.lang.String getTimeFormat()
setTimeFormat(java.lang.String), or the patten specified in the
property in the
file.
public void setSourceFormat(java.lang.String format)
"none",
"logger:short", "class:short",
"logger:long" or "class:long".
The difference between a and "none" is that
may be replaced by a default value, while "none" means that the user explicitly
requested no source.
format - The format for displaying the source, or
to disable source formatting.public java.lang.String getSourceFormat()
setSourceFormat(java.lang.String), or the patten specified in the
property in the
file.
public java.lang.String format(java.util.logging.LogRecord record)
record - the log record to be formatted.
public static MonolineFormatter init(java.lang.String base)
ConsoleHandler
using the SimpleFormatter. If such instances are found, they are
replaced by a single instance of writting
to the standard output stream (instead of the
standard error stream). If no such ConsoleHandler
are found, then a new one is created with this .
This action has no effect on any loggers outside the namespace.
base - The base logger name to apply the change on (e.g. "org.geotools").
setTimeFormat(java.lang.String)
and setSourceFormat(java.lang.String) methods.
public static MonolineFormatter init(java.lang.String base,
java.util.logging.Level level)
init(String), except that it accepts an optional level
argument. If the level is non-null, then all Handlers using the monoline formatter
will be set to the specified level. The logger named will also be set to
this level.
Note: Avoid this method as much as possible, since it overrides user's level setting for the logger. A user trying to configure its logging properties may find confusing to see his setting ignored.
base - The base logger name to apply the change on (e.g. "org.geotools").level - The desired level, or if no level should be set.
setTimeFormat(java.lang.String)
and setSourceFormat(java.lang.String) methods.public static void initGeotools()
public static void initGeotools(java.util.logging.Level level)
level - The logging level, or if no level should be set.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||