|
|||||||||||
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 MonolineFormatter
looks like:
By default,FINE core - A log message logged with level FINE from the "org.geotools.core" logger.
MonolineFormatter
display only the level and the
message. Additional fields can be formatted if 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 jre/lib/logging.properties
file. For example, user can cut and paste the following properties into
logging.properties
:
If the############################################################ # 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
MonolineFormatter
is wanted for the whole system
(not just the org.geotools
packages) with level FINE (for
example), then the following properties can be defined as below:
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 . |
|
MonolineFormatter(java.lang.String base)
Construct a MonolineFormatter . |
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 MonolineFormatter for the specified logger and its
children. |
static MonolineFormatter |
init(java.lang.String base,
java.util.logging.Level level)
Convenience method setting both a MonolineFormatter and the logger levels.
|
static void |
initGeotools()
Initialise the formatter for the " org.geotools " loggers. |
static void |
initGeotools(java.util.logging.Level level)
Initialise the formatter for the " org.geotools " 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()
MonolineFormatter
.
public MonolineFormatter(java.lang.String base)
MonolineFormatter
.
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 null
to disable time
formatting.public java.lang.String getTimeFormat()
setTimeFormat(java.lang.String)
, or the patten specified in the
org.geotools.MonolineFormater.time
property in the
jre/lib/logging.properties
file.
null
if time is not formatted.public void setSourceFormat(java.lang.String format)
"none"
,
"logger:short"
, "class:short"
,
"logger:long"
or "class:long"
.
The difference between a null
and "none"
is that null
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 null
to disable source formatting.public java.lang.String getSourceFormat()
setSourceFormat(java.lang.String)
, or the patten specified in the
org.geotools.MonolineFormater.source
property in the
jre/lib/logging.properties
file.
null
if source is not formatted.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)
MonolineFormatter
for the specified logger and its
children. This method search for all instances of ConsoleHandler
using the SimpleFormatter
. If such instances are found, they are
replaced by a single instance of MonolineFormatter
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 MonolineFormatter
.
This action has no effect on any loggers outside the base
namespace.
base
- The base logger name to apply the change on (e.g. "org.geotools").
MonolineFormatter
(never null
).
The formatter output can be configured using the setTimeFormat(java.lang.String)
and setSourceFormat(java.lang.String)
methods.public static MonolineFormatter init(java.lang.String base, java.util.logging.Level level)
MonolineFormatter
and the logger levels.
This method behave like init(String)
, except that it accepts an optional level
argument. If the level is non-null, then all Handler
s using the monoline formatter
will be set to the specified level. The logger named base
will also be set to
this level.
base
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 null
if no level should be set.
MonolineFormatter
(never null
).
The formatter output can be configured using the setTimeFormat(java.lang.String)
and setSourceFormat(java.lang.String)
methods.public static void initGeotools()
org.geotools
" loggers.
public static void initGeotools(java.util.logging.Level level)
org.geotools
" loggers with the specified
level. NOTE: Avoid this method as much as possible, since it overrides
user's level setting for the "org.geotools
" logger. A user trying to
configure its logging properties may find confusing to see his setting ignored.
level
- The logging level, or null
if no level should be set.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |