| java.lang.Object org.geotools.util.logging.Logging
Logging | final public class Logging (Code) | | A set of utilities method for configuring loggings in GeoTools. All GeoTools
code should fetch their logger through a call to
Logging.getLogger(String) ,
not
Logger.getLogger(String) . This is necessary in order to give GeoTools a
chance to redirect log events to an other logging framework, for example
commons-logging.
Example: In order to redirect every GeoTools log events to Commons-logging,
invoke the following once at application startup:
Logging.
.
("org.geotools.util.logging.CommonsLoggerFactory");
since: 2.4 version: $Id: Logging.java 27891 2007-11-14 14:10:48Z desruisseaux $ author: Martin Desruisseaux |
Field Summary | |
final public static Logging | ALL Logging configuration that apply to all packages. | final public static Logging | GEOTOOLS Logging configuration that apply only to GeoTools packages. | final String | name The name of the base package. |
ALL | final public static Logging ALL(Code) | | Logging configuration that apply to all packages.
|
GEOTOOLS | final public static Logging GEOTOOLS(Code) | | Logging configuration that apply only to GeoTools packages.
|
forceMonolineConsoleOutput | public void forceMonolineConsoleOutput(Level level)(Code) | | Same as
Logging.forceMonolineConsoleOutput() , but additionnaly set an optional logging
level. If the specified level is non-null, then all
java.util.logging.Handler s
using the monoline formatter will be set to the specified level.
Note: Avoid this method as much as possible, since it overrides user's level
setting. A user trying to configure his logging properties may find confusing to see
his setting ignored.
See Also: org.geotools.factory.GeoTools.init |
getLogger | public static Logger getLogger(String name)(Code) | | Returns a logger for the specified name. If a
has
been set, then this method first
.
It gives GeoTools a chance to redirect logging events to
commons-logging
or some equivalent framework.
If no factory was found or if the factory choose to not redirect the loggings, then this
method returns the usual
(name) .
Parameters: name - The logger name. A logger for the specified name. |
getLoggerFactory | public LoggerFactory getLoggerFactory()(Code) | | Returns the logger factory, or
null if none. This method returns the logger set
by the last call to
Logging.setLoggerFactory on this
Logging instance or on one
of its parent.
|
getLogging | public static Logging getLogging(String name)(Code) | | Returns a
Logging instance for the specified base logger. This instance is
used for controlling logging configuration in GeoTools. For example methods like
Logging.forceMonolineConsoleOutput are invoked on a
Logging instance.
Logging instances follow the same hierarchy than
Logger , i.e.
"org.geotools" is the parent of
"org.geotools.referencing" ,
"org.geotools.metadata" , etc.
Parameters: name - The base logger name. |
setLoggerFactory | public void setLoggerFactory(LoggerFactory factory)(Code) | | Sets a new logger factory for this
Logging instance and every children. The
specified factory will be used by
(name)
when
name is this
Logging name or one of its children.
|
unexpectedException | public static boolean unexpectedException(Logger logger, Throwable error)(Code) | | Invoked when an unexpected error occurs. This method logs a message at the
Level.WARNING WARNING level to the specified logger. The originating
class name and method name are inferred from the error stack trace, using the
first
for which the class
name is inside a package or sub-package of the logger name. For example if
the logger name is
"org.geotools.image" , then this method will uses
the first stack trace element where the fully qualified class name starts with
"org.geotools.image" or
"org.geotools.image.io" , but not
"org.geotools.imageio" .
Parameters: logger - Where to log the error. Parameters: error - The error that occured. true if the error has been logged, or false if the loggerdoesn't log anything at the Level.WARNING WARNING level. |
unexpectedException | public static void unexpectedException(Logger logger, Class classe, String method, Throwable error)(Code) | | Invoked when an unexpected error occurs. This method logs a message at the
Level.WARNING WARNING level to the specified logger. The originating
class name and method name can optionnaly be specified. If any of them is
null , then it will be inferred from the error stack trace as in
Logging.unexpectedException(Logger,Throwable) .
Explicit value for class and method names are sometime preferred to automatic
inference for the following reasons:
Automatic inference is not 100% reliable, since the Java Virtual Machine
is free to omit stack frame in optimized code.
When an exception occured in a private method used internally by a public
method, we sometime want to log the warning for the public method instead,
since the user is not expected to know anything about the existence of the
private method. If a developper really want to know about the private method,
the stack trace is still available anyway.
Parameters: logger - Where to log the error. Parameters: classe - The class where the error occurred, or null . Parameters: method - The method where the error occurred, or null . Parameters: error - The error. |
unexpectedException | public static void unexpectedException(String paquet, Class classe, String method, Throwable error)(Code) | | Invoked when an unexpected error occurs. This method logs a message at the
Level.WARNING WARNING level to the logger for the specified package
name. The originating class name and method name can optionnaly be specified.
If any of them is
null , then it will be inferred from the error stack
trace as in
Logging.unexpectedException(Logger,Throwable) .
Parameters: paquet - The package where the error occurred, or null . Thisinformation is used for fetching an appropriate Loggerfor logging the error. Parameters: classe - The class where the error occurred, or null . Parameters: method - The method where the error occurred, or null . Parameters: error - The error. |
|
|