org.apache.juli.logging.LogFactory类的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(9.8k)|赞(0)|评价(0)|浏览(181)

本文整理了Java中org.apache.juli.logging.LogFactory类的一些代码示例,展示了LogFactory类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LogFactory类的具体详情如下:
包路径:org.apache.juli.logging.LogFactory
类名称:LogFactory

LogFactory介绍

[英]Modified LogFactory: removed all discovery, hardcode a specific implementation If you like a different logging implementation - use either the discovery-based commons-logging, or better - another implementation hardcoded to your favourite logging impl. Why ? Each application and deployment can choose a logging implementation - that involves configuration, installing the logger jar and optional plugins, etc. As part of this process - they can as well install the commons-logging implementation that corresponds to their logger of choice. This completely avoids any discovery problem, while still allowing the user to switch. Note that this implementation is not just a wrapper around JDK logging ( like the original commons-logging impl ). It adds 2 features - a simpler configuration ( which is in fact a subset of log4j.properties ) and a formatter that is less ugly. The removal of 'abstract' preserves binary backward compatibility. It is possible to preserve the abstract - and introduce another ( hardcoded ) factory - but I see no benefit. Since this class is not intended to be extended - and provides no plugin for other LogFactory implementation - all protected methods are removed. This can be changed - but again, there is little value in keeping dead code. Just take a quick look at the removed code ( and it's complexity) -------------- Original comment:

Factory for creating Log instances, with discovery and configuration features similar to that employed by standard Java APIs such as JAXP.

IMPLEMENTATION NOTE - This implementation is heavily based on the SAXParserFactory and DocumentBuilderFactory implementations (corresponding to the JAXP pluggability APIs) found in Apache Xerces.
[中]Modified LogFactory:删除所有发现,如果您喜欢不同的日志实现,请硬编码特定实现-使用基于发现的commons日志,或者更好-另一个硬编码到您最喜欢的日志impl的实现。为什么?每个应用程序和部署都可以选择一个日志实现——包括配置、安装记录器jar和可选插件等。作为此过程的一部分,他们还可以安装与其选择的记录器相对应的commons日志实现。这完全避免了任何发现问题,同时仍然允许用户切换。请注意,此实现不仅仅是JDK日志的包装器(如原始commons logging impl)。它增加了两个特性——一个更简单的配置(实际上是log4j.properties的子集)和一个不那么难看的格式化程序。删除“abstract”保留了二进制向后兼容性。保留抽象是可能的——并引入另一个(硬编码)工厂——但我看不到任何好处。由于该类不打算扩展,并且没有为其他LogFactory实现提供插件,因此所有受保护的方法都将被删除。这是可以改变的——但同样,保留死代码没有什么价值。只需快速查看已删除的代码(及其复杂性)----原始注释:
用于创建日志实例的工厂,其发现和配置功能与标准JavaAPI(如JAXP)所采用的类似。
实现说明-此实现主要基于ApacheXerces中的SAXParserFactory和DocumentBuilderFactory实现(对应于JAXP可插拔性API)。

代码示例

代码示例来源:origin: apache/geode

@Override
public Log getLogger() {
 if (LOGGER == null) {
  LOGGER = LogFactory.getLog(DeltaSessionManager.class);
 }
 return LOGGER;
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Release any internal references to previously created {@link LogFactory}
 * instances, after calling the instance method <code>release()</code> on
 * each of them.  This is useful in environments like servlet containers,
 * which implement application reloading by throwing away a ClassLoader.
 * Dangling references to objects in that class loader would prevent
 * garbage collection.
 */
public static void releaseAll() {
  singleton.release();
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Convenience method to return a named logger, without the application
 * having to care about factories.
 *
 * @param clazz Class from which a log name will be derived
 *
 * @exception LogConfigurationException if a suitable <code>Log</code>
 *  instance cannot be returned
 */
public static Log getLog(Class<?> clazz)
  throws LogConfigurationException {
  return (getFactory().getInstance(clazz));
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Convenience method to derive a name from the specified class and
 * call <code>getInstance(String)</code> with it.
 *
 * @param clazz Class for which a suitable Log name will be derived
 *
 * @exception LogConfigurationException if a suitable <code>Log</code>
 *  instance cannot be returned
 */
public Log getInstance(Class<?> clazz)
  throws LogConfigurationException {
  return getInstance( clazz.getName());
}

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

/**
 * Convenience method to derive a name from the specified class and
 * call <code>getInstance(String)</code> with it.
 *
 * @param clazz Class for which a suitable Log name will be derived
 *
 * @exception LogConfigurationException if a suitable <code>Log</code>
 *  instance cannot be returned
 */
public Log getInstance(Class<?> clazz)
  throws LogConfigurationException {
  return getInstance( clazz.getName());
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Convenience method to return a named logger, without the application
 * having to care about factories.
 *
 * @param name Logical name of the <code>Log</code> instance to be
 *  returned (the meaning of this name is only known to the underlying
 *  logging implementation that is being wrapped)
 *
 * @exception LogConfigurationException if a suitable <code>Log</code>
 *  instance cannot be returned
 */
public static Log getLog(String name)
  throws LogConfigurationException {
  return (getFactory().getInstance(name));
}

代码示例来源:origin: magro/memcached-session-manager

public static void initLogConfig(@SuppressWarnings("rawtypes") final Class<? extends TestUtils> clazz) {
  final URL loggingProperties = clazz.getResource("/logging.properties");
  try {
    System.setProperty("java.util.logging.config.file", new File(loggingProperties.toURI()).getAbsolutePath());
  } catch (final Exception e) {
    // we don't have a plain file (e.g. the case for msm-kryo-serializer etc), so we can skip reading the config
    return;
  }
  try {
    LogManager.getLogManager().readConfiguration();
  } catch (final Exception e) {
    LogFactory.getLog( TestUtils.class ).error("Could not init logging configuration.", e);
  }
}

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

/**
 * Release any internal references to previously created {@link LogFactory}
 * instances, after calling the instance method <code>release()</code> on
 * each of them.  This is useful in environments like servlet containers,
 * which implement application reloading by throwing away a ClassLoader.
 * Dangling references to objects in that class loader would prevent
 * garbage collection.
 */
public static void releaseAll() {
  singleton.release();
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9

/**
 * Convenience method to derive a name from the specified class and
 * call <code>getInstance(String)</code> with it.
 *
 * @param clazz Class for which a suitable Log name will be derived
 *
 * @exception LogConfigurationException if a suitable <code>Log</code>
 *  instance cannot be returned
 */
public Log getInstance(Class<?> clazz)
  throws LogConfigurationException {
  return getInstance( clazz.getName());
}

代码示例来源:origin: codefollower/Tomcat-Research

/**
 * Convenience method to return a named logger, without the application
 * having to care about factories.
 *
 * @param clazz Class from which a log name will be derived
 *
 * @exception LogConfigurationException if a suitable <code>Log</code>
 *  instance cannot be returned
 */
public static Log getLog(Class<?> clazz)
  throws LogConfigurationException {
  return (getFactory().getInstance(clazz));
}

代码示例来源:origin: org.apache.tomcat/tomcat-tribes

private Log getLog() {
    if (log == null) {
      synchronized (this) {
        if (log == null) {
          log = LogFactory.getLog(LazyReplicatedMap.class);
        }
      }
    }
    return log;
  }
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7

/**
 * Release any internal references to previously created {@link LogFactory}
 * instances, after calling the instance method <code>release()</code> on
 * each of them.  This is useful in environments like servlet containers,
 * which implement application reloading by throwing away a ClassLoader.
 * Dangling references to objects in that class loader would prevent
 * garbage collection.
 */
public static void releaseAll() {
  singleton.release();
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7

/**
 * Convenience method to derive a name from the specified class and
 * call <code>getInstance(String)</code> with it.
 *
 * @param clazz Class for which a suitable Log name will be derived
 *
 * @exception LogConfigurationException if a suitable <code>Log</code>
 *  instance cannot be returned
 */
public Log getInstance(Class<?> clazz)
  throws LogConfigurationException {
  return getInstance( clazz.getName());
}

代码示例来源:origin: org.apache.geronimo.ext.tomcat/juli

/**
 * Convenience method to return a named logger, without the application
 * having to care about factories.
 *
 * @param clazz Class from which a log name will be derived
 *
 * @exception LogConfigurationException if a suitable <code>Log</code>
 *  instance cannot be returned
 */
public static Log getLog(Class<?> clazz)
  throws LogConfigurationException {
  return (getFactory().getInstance(clazz));
}

代码示例来源:origin: org.apache.geode/geode-modules

@Override
public Log getLogger() {
 if (LOGGER == null) {
  LOGGER = LogFactory.getLog(DeltaSessionManager.class);
 }
 return LOGGER;
}

代码示例来源:origin: org.apache.geronimo.ext.tomcat/juli

/**
 * Release any internal references to previously created {@link LogFactory}
 * instances, after calling the instance method <code>release()</code> on
 * each of them.  This is useful in environments like servlet containers,
 * which implement application reloading by throwing away a ClassLoader.
 * Dangling references to objects in that class loader would prevent
 * garbage collection.
 */
public static void releaseAll() {
  singleton.release();
}

代码示例来源:origin: codefollower/Tomcat-Research

/**
 * Convenience method to derive a name from the specified class and
 * call <code>getInstance(String)</code> with it.
 *
 * @param clazz Class for which a suitable Log name will be derived
 *
 * @exception LogConfigurationException if a suitable <code>Log</code>
 *  instance cannot be returned
 */
public Log getInstance(Class<?> clazz)
  throws LogConfigurationException {
  return getInstance( clazz.getName());
}

代码示例来源:origin: org.apache.openejb/tomee-juli

public static Log getLog(final Class<?> clazz)
  throws LogConfigurationException {
  return getFactory().getInstance(clazz);
}

代码示例来源:origin: org.apache.tomcat/tomcat-tribes

private Log getLog() {
    if (log == null) {
      synchronized (this) {
        if (log == null) {
          log = LogFactory.getLog(ReplicatedMap.class);
        }
      }
    }
    return log;
  }
}

代码示例来源:origin: org.apache.juli/com.springsource.org.apache.juli.extras

/**
 * Release any internal references to previously created {@link LogFactory}
 * instances, after calling the instance method <code>release()</code> on
 * each of them.  This is useful in environments like servlet containers,
 * which implement application reloading by throwing away a ClassLoader.
 * Dangling references to objects in that class loader would prevent
 * garbage collection.
 */
public static void releaseAll() {
  singleton.release();
}

相关文章