本文整理了Java中org.geotools.util.logging.Logging
类的一些代码示例,展示了Logging
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logging
类的具体详情如下:
包路径:org.geotools.util.logging.Logging
类名称:Logging
[英]A set of utilities method for configuring loggings in GeoTools. All GeoTools code should fetch their logger through a call to #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. #GEOTOOLS. #setLoggerFactory("org.geotools.util.logging.CommonsLoggerFactory");
[中]用于在GeoTools中配置日志的一组实用工具方法。所有GeoTools代码都应该通过调用#getLogger(String),而不是logger#getLogger(String)来获取记录器。这是必要的,以便GeoTools有机会将日志事件重定向到其他日志框架,例如commons-logging。
示例:为了将每个GeoTools日志事件重定向到Commons日志,请在应用程序启动时调用以下命令一次:Logging. #GEOTOOLS. #setLoggerFactory("org.geotools.util.logging.CommonsLoggerFactory");
代码示例来源:origin: geoserver/geoserver
Logger getLogger() {
if (LOGGER == null) {
LOGGER = Logging.getLogger("org.geoserver.logging");
}
return LOGGER;
}
}
代码示例来源:origin: geoserver/geoserver
/**
* Invoked when an error occurs during the initialization.
*
* @param e the error that occured.
*/
private static void unexpectedException(final Exception e) {
Logging.unexpectedException("org.geotools.resources", Log4JFormatter.class, "init", e);
}
代码示例来源:origin: geoserver/geoserver
try {
if (logging == GeoToolsLoggingRedirection.CommonsLogging) {
Logging.ALL.setLoggerFactory(CommonsLoggerFactory.getInstance());
} else if (logging != GeoToolsLoggingRedirection.JavaLogging) {
Logging.ALL.setLoggerFactory(Log4JLoggerFactory.getInstance());
代码示例来源:origin: geotools/geotools
/**
* Sets a new logger factory for this {@code Logging} instance and every children. The specified
* factory will be used by <code>{@linkplain #getLogger(String) getLogger}(name)</code> when
* {@code name} is this {@code Logging} name or one of its children.
*/
public void setLoggerFactory(final LoggerFactory<?> factory) {
synchronized (EMPTY) {
this.factory = factory;
for (int i = 0; i < children.length; i++) {
children[i].setLoggerFactory(factory);
}
sameLoggerFactory = sameLoggerFactory(ALL.children, ALL.factory);
}
}
代码示例来源:origin: geotools/geotools
/** Logs the specified record. */
private static void log(final String method, final LogRecord record) {
record.setSourceClassName(Registry.class.getName());
record.setSourceMethodName(method);
final Logger logger = Logging.getLogger(Registry.class);
record.setLoggerName(logger.getName());
logger.log(record);
}
}
代码示例来源:origin: geotools/geotools
new LogRecord(Level.FINER, "Loaded resources for {0} from bundle \"{1}\".");
record.setSourceClassName(getClass().getName());
record.setSourceMethodName((key != null) ? "getObject" : "getKeys");
record.setParameters(new String[] {language, getPackageName()});
final Logger logger = Logging.getLogger(IndexedResourceBundle.class);
record.setLoggerName(logger.getName());
logger.log(record);
record.setMessage(exception.getLocalizedMessage());
record.setThrown(exception);
final Logger logger = Logging.getLogger(IndexedResourceBundle.class);
record.setLoggerName(logger.getName());
logger.log(record);
代码示例来源:origin: geotools/geotools
/**
* Logs a warning. This method is invoked automatically by the {@link #parse parse} method when
* a text can't be fully parsed. The default implementation logs the warning to the logger
* specified by the last call to the {@link #setLogger setLogger} method. Subclasses may
* override this method if they want to change the log record before the logging.
*
* @param warning The warning to log.
*/
protected void logWarning(final LogRecord warning) {
if (logger != null) {
final Logger logger = Logging.getLogger(this.logger);
warning.setLoggerName(logger.getName());
logger.log(warning);
}
}
代码示例来源:origin: org.geotools/gt2-coverage
/**
* Log the specified record.
*/
private static void log(final String method, final LogRecord record) {
record.setSourceClassName(Registry.class.getName());
record.setSourceMethodName(method);
org.geotools.util.logging.Logging.getLogger("org.geotools.image").log(record);
}
}
代码示例来源:origin: org.geotools/gt2-metadata
/**
* Invoked when a recoverable error occurs. This exception is similar to
* {@link #unexpectedException unexpectedException} except that it doesn't
* log the stack trace and uses a lower logging level.
*
* @param paquet The package where the error occurred. This information
* may be used to fetch an appropriate {@link Logger} for
* logging the error.
* @param classe The class where the error occurred.
* @param method The method name where the error occurred.
* @param error The error.
*/
public static void recoverableException(final String paquet,
final Class classe,
final String method,
final Throwable error)
{
final LogRecord record = getLogRecord(error);
record.setLevel(Level.FINER);
record.setSourceClassName (classe.getName());
record.setSourceMethodName(method);
Logging.getLogger(paquet).log(record);
}
代码示例来源:origin: org.geotools/gt-epsg-hsql
final Logger logger = Logging.getLogger(LOGGER);
logger.log(Level.FINE, "Building backing store for " + getClass().getName());
record.setLoggerName(logger.getName());
logger.log(record);
SQLException e = new SQLException(Errors.format(ErrorKeys.CANT_READ_$1, ZIP_FILE));
代码示例来源:origin: org.geotools/gt-render
private final static Logger LOGGER = org.geotools.util.logging.Logging.getLogger(RendererUtilities.class.getName());
throw new UnsupportedOperationException(Errors.format(
ErrorKeys.CANT_REDUCE_TO_TWO_DIMENSIONS_$1, crs));
代码示例来源:origin: geotools/geotools
/**
* Invoked when an unexpected error occurs. This method logs a message at the {@link
* 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 {@code null}, then
* it will be inferred from the error stack trace as in {@link #unexpectedException(Logger,
* Throwable)}.
*
* @param paquet The package where the error occurred, or {@code null}. This information is used
* for fetching an appropriate {@link Logger} for logging the error.
* @param classe The class where the error occurred, or {@code null}.
* @param method The method where the error occurred, or {@code null}.
* @param error The error.
* @return {@code true} if the error has been logged, or {@code false} if the logger doesn't log
* anything at the {@link Level#WARNING WARNING} level.
* @deprecated Use one of the other {@code unexpectedException} methods instead.
*/
public static boolean unexpectedException(
final String paquet,
final Class<?> classe,
final String method,
final Throwable error) {
final Logger logger = (paquet != null) ? getLogger(paquet) : null;
return unexpectedException(logger, classe, method, error);
}
代码示例来源:origin: org.geotools/gt2-coverage
Logging.GEOTOOLS.unexpectedException(AbstractProcessor.LOGGER,
OperationJAI.class, "getOperationDescriptor", e);
throw new OperationNotFoundException(Errors.format(ErrorKeys.OPERATION_NOT_FOUND_$1, name));
代码示例来源:origin: org.geotools/gt-metadata
factoryClass = Class.forName(className);
} catch (NoClassDefFoundError error) {
throw factoryNotFound(className, error);
throw new IllegalArgumentException(Errors.format(
ErrorKeys.ILLEGAL_CLASS_$2, factoryClass, LoggerFactory.class));
throw factoryNotFound(className, (NoClassDefFoundError) cause);
throw new IllegalArgumentException(Errors.format(
ErrorKeys.CANT_CREATE_FACTORY_$1, className, cause));
setLoggerFactory(factory);
代码示例来源:origin: geotools/geotools
final Logging log = Logging.GEOTOOLS;
try {
log.setLoggerFactory("org.geotools.util.logging.CommonsLoggerFactory");
} catch (ClassNotFoundException commonsException) {
try {
log.setLoggerFactory("org.geotools.util.logging.Log4JLoggerFactory");
} catch (ClassNotFoundException log4jException) {
if (log.getLoggerFactory() == null) {
log.forceMonolineConsoleOutput();
代码示例来源:origin: geotools/geotools
/**
* Configures the default {@linkplain java.util.logging.ConsoleHandler console handler} in order
* to log records on a single line instead of two lines. More specifically, for each {@link
* java.util.logging.ConsoleHandler} using a {@link java.util.logging.SimpleFormatter}, this
* method replaces the simple formatter by an instance of {@link MonolineFormatter}. If no
* {@code ConsoleHandler} are found, then a new one is created.
*
* <p><b>Note:</b> this method may have no effect if the loggings are redirected to an other
* logging framework, for example if {@link #redirectToCommonsLogging} has been invoked.
*/
public void forceMonolineConsoleOutput() {
forceMonolineConsoleOutput(null);
}
代码示例来源:origin: geotools/geotools
factoryClass = Class.forName(className);
} catch (NoClassDefFoundError error) {
throw factoryNotFound(className, error);
throw factoryNotFound(className, (NoClassDefFoundError) cause);
setLoggerFactory(factory);
代码示例来源:origin: geotools/geotools
/** Invoked when a recoverable exception occured. */
private static void recoverableException(final String method, final SQLException exception) {
// Uses the FINE level instead of WARNING because it may be a recoverable error.
LogRecord record = Loggings.format(Level.FINE, LoggingKeys.UNEXPECTED_EXCEPTION);
record.setSourceClassName(AuthorityCodes.class.getName());
record.setSourceMethodName(method);
record.setThrown(exception);
final Logger logger = Logging.getLogger(AuthorityCodes.class);
record.setLoggerName(logger.getName());
logger.log(record);
}
代码示例来源:origin: org.geotools/gt-metadata
record= new LogRecord(Level.FINER, "Loaded resources for {0} from bundle \"{1}\".");
record.setSourceClassName (getClass().getName());
record.setSourceMethodName((key != null) ? "getObject" : "getKeys");
record.setParameters(new String[]{language, getPackageName()});
final Logger logger = Logging.getLogger(IndexedResourceBundle.class);
record.setLoggerName(logger.getName());
logger.log(record);
record.setMessage(exception.getLocalizedMessage());
record.setThrown (exception);
final Logger logger = Logging.getLogger(IndexedResourceBundle.class);
record.setLoggerName(logger.getName());
logger.log(record);
代码示例来源:origin: geotools/geotools
final Logger logger = Logging.getLogger(ThreadedHsqlEpsgFactory.class);
logger.log(Level.FINE, "Building backing store for " + getClass().getName());
LoggingKeys.CREATING_CACHED_EPSG_DATABASE_$1,
VERSION);
record.setLoggerName(logger.getName());
logger.log(record);
内容来源于网络,如有侵权,请联系作者删除!