org.apache.commons.logging.LogFactory.logDiagnostic()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(13.8k)|赞(0)|评价(0)|浏览(101)

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

LogFactory.logDiagnostic介绍

[英]Write the specified message to the internal logging destination.

Note that this method is private; concrete subclasses of this class should not call it because the diagnosticPrefix string this method puts in front of all its messages is LogFactory@...., while subclasses should put SomeSubClass@...

Subclasses should instead compute their own prefix, then call logRawDiagnostic. Note that calling isDiagnosticsEnabled is fine for subclasses.

Note that it is safe to call this method before initDiagnostics is called; any output will just be ignored (as isDiagnosticsEnabled will return false).
[中]将指定的消息写入内部日志记录目标。
注意这个方法是私有的;这个类的具体子类不应该调用它,因为这个方法放在所有消息前面的diagnosticPrefix字符串是LogFactory@....,而子类应SomeSubClass@...
子类应该计算它们自己的前缀,然后调用logRawDiagnostic。注意,对子类调用isDiagnosticsEnabled是可以的。
请注意,在调用initDiagnostics之前调用此方法是安全的;任何输出都将被忽略(因为isDiagnosticsEnabled将返回false)。

代码示例

代码示例来源:origin: commons-logging/commons-logging

ClassLoader logFactoryClassLoader = logFactoryClass.getClassLoader();
  if (logFactoryClassLoader == null) {
    logDiagnostic("[CUSTOM LOG FACTORY] was loaded by the boot classloader");
  } else {
    logHierarchy("[CUSTOM LOG FACTORY] ", logFactoryClassLoader);
    implementsLogFactory = factoryFromCustomLoader.isAssignableFrom(logFactoryClass);
    if (implementsLogFactory) {
      logDiagnostic("[CUSTOM LOG FACTORY] " + logFactoryClass.getName() +
             " implements LogFactory but was loaded by an incompatible classloader.");
    } else {
      logDiagnostic("[CUSTOM LOG FACTORY] " + logFactoryClass.getName() +
             " does not implement LogFactory.");
  logDiagnostic("[CUSTOM LOG FACTORY] SecurityException thrown whilst trying to determine whether " +
         "the compatibility was caused by a classloader conflict: " + e.getMessage());
} catch (LinkageError e) {
  logDiagnostic("[CUSTOM LOG FACTORY] LinkageError thrown whilst trying to determine whether " +
         "the compatibility was caused by a classloader conflict: " + e.getMessage());
} catch (ClassNotFoundException e) {
  logDiagnostic("[CUSTOM LOG FACTORY] LogFactory class cannot be loaded by classloader which loaded " +
         "the custom LogFactory implementation. Is the custom factory in the right classloader?");

代码示例来源:origin: commons-logging/commons-logging

logDiagnostic("[ENV] Extension directories (java.ext.dir): " + System.getProperty("java.ext.dir"));
  logDiagnostic("[ENV] Application classpath (java.class.path): " + System.getProperty("java.class.path"));
} catch (SecurityException ex) {
  logDiagnostic("[ENV] Security setting prevent interrogation of system classpaths.");
} catch (SecurityException ex) {
  logDiagnostic("[ENV] Security forbids determining the classloader for " + className);
  return;
logDiagnostic("[ENV] Class " + className + " was loaded via classloader " + objectId(classLoader));
logHierarchy("[ENV] Ancestry of classloader which loaded " + className + " is ", classLoader);

代码示例来源:origin: commons-logging/commons-logging

} catch (SecurityException ex) {
  if (isDiagnosticsEnabled()) {
    logDiagnostic("Unable to get classloader for class '" + clazz +
           "' due to security restrictions - " + ex.getMessage());

代码示例来源:origin: commons-logging/commons-logging

if (classLoader != null) {
  final String classLoaderString = classLoader.toString();
  logDiagnostic(prefix + objectId(classLoader) + " == '" + classLoaderString + "'");
  systemClassLoader = ClassLoader.getSystemClassLoader();
} catch (SecurityException ex) {
  logDiagnostic(prefix + "Security forbids determining the system classloader.");
  return;
  logDiagnostic(buf.toString());

代码示例来源:origin: robovm/robovm

ClassLoader logFactoryClassLoader = logFactoryClass.getClassLoader();
if (logFactoryClassLoader == null) {
  logDiagnostic("[CUSTOM LOG FACTORY] was loaded by the boot classloader");
} else {
  logHierarchy("[CUSTOM LOG FACTORY] ", logFactoryClassLoader);
  implementsLogFactory = factoryFromCustomLoader.isAssignableFrom(logFactoryClass);
  if (implementsLogFactory) {
    logDiagnostic("[CUSTOM LOG FACTORY] " + logFactoryClass.getName()
        + " implements LogFactory but was loaded by an incompatible classloader.");
  } else {
    logDiagnostic("[CUSTOM LOG FACTORY] " + logFactoryClass.getName()
        + " does not implement LogFactory.");
logDiagnostic("[CUSTOM LOG FACTORY] SecurityException thrown whilst trying to determine whether " +
    "the compatibility was caused by a classloader conflict: "
    + e.getMessage());
logDiagnostic("[CUSTOM LOG FACTORY] LinkageError thrown whilst trying to determine whether " +
    "the compatibility was caused by a classloader conflict: "
    + e.getMessage());
logDiagnostic("[CUSTOM LOG FACTORY] LogFactory class cannot be loaded by classloader which loaded the " +
    "custom LogFactory implementation. Is the custom factory in the right classloader?");

代码示例来源:origin: commons-logging/commons-logging

/**
 * 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() {
  if (isDiagnosticsEnabled()) {
    logDiagnostic("Releasing factory for all classloaders.");
  }
  // factories is not final and could be replaced in this block.
  final Hashtable factories = LogFactory.factories;
  synchronized (factories) {
    final Enumeration elements = factories.elements();
    while (elements.hasMoreElements()) {
      LogFactory element = (LogFactory) elements.nextElement();
      element.release();
    }
    factories.clear();
    if (nullClassLoaderFactory != null) {
      nullClassLoaderFactory.release();
      nullClassLoaderFactory = null;
    }
  }
}

代码示例来源:origin: robovm/robovm

logDiagnostic("[ENV] Extension directories (java.ext.dir): " + System.getProperty("java.ext.dir"));
  logDiagnostic("[ENV] Application classpath (java.class.path): " + System.getProperty("java.class.path"));
} catch(SecurityException ex) {
  logDiagnostic("[ENV] Security setting prevent interrogation of system classpaths.");
} catch(SecurityException ex) {
  logDiagnostic(
    "[ENV] Security forbids determining the classloader for " + className);
  return;
logDiagnostic(
  "[ENV] Class " + className + " was loaded via classloader "
  + objectId(classLoader));

代码示例来源:origin: robovm/robovm

} catch(SecurityException ex) {
  if (isDiagnosticsEnabled()) {
    logDiagnostic(
        "Unable to get classloader for class '" + clazz
        + "' due to security restrictions - " + ex.getMessage());

代码示例来源:origin: commons-logging/commons-logging

logDiagnostic("[LOOKUP] Properties file found at '" + url + "'" +
               " with priority " + priority);
          logDiagnostic("[LOOKUP] Properties file at '" + url + "'" +
                 " with priority " + newPriority +
                 " overrides file at '" + propsUrl + "'" +
      } else {
        if (isDiagnosticsEnabled()) {
          logDiagnostic("[LOOKUP] Properties file at '" + url + "'" +
                 " with priority " + newPriority +
                 " does not override file at '" + propsUrl + "'" +
  logDiagnostic("SecurityException thrown while trying to find/read config files.");
  logDiagnostic("[LOOKUP] No properties file of name '" + fileName + "' found.");
} else {
  logDiagnostic("[LOOKUP] Properties file of name '" + fileName + "' found at '" + propsUrl + '"');

代码示例来源:origin: robovm/robovm

logDiagnostic("[ERROR] LogFactory: Load of custom hashtable failed");
} else {

代码示例来源:origin: robovm/robovm

if (classLoader != null) {
  final String classLoaderString = classLoader.toString();
  logDiagnostic(prefix + objectId(classLoader) + " == '" + classLoaderString + "'");
  systemClassLoader = ClassLoader.getSystemClassLoader();
} catch(SecurityException ex) {
  logDiagnostic(
      prefix + "Security forbids determining the system classloader.");
  return;
  logDiagnostic(buf.toString());

代码示例来源:origin: commons-logging/commons-logging

logDiagnostic("[ERROR] LogFactory: Load of custom hashtable failed");
} else {

代码示例来源:origin: robovm/robovm

/**
 * 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() {
  if (isDiagnosticsEnabled()) {
    logDiagnostic("Releasing factory for all classloaders.");
  }
  synchronized (factories) {
    Enumeration elements = factories.elements();
    while (elements.hasMoreElements()) {
      LogFactory element = (LogFactory) elements.nextElement();
      element.release();
    }
    factories.clear();
    if (nullClassLoaderFactory != null) {
      nullClassLoaderFactory.release();
      nullClassLoaderFactory = null;
    }
  }
}

代码示例来源:origin: commons-logging/commons-logging

/**
 * Release any internal references to previously created {@link LogFactory}
 * instances that have been associated with the specified class loader
 * (if any), after calling the instance method <code>release()</code> on
 * each of them.
 *
 * @param classLoader ClassLoader for which to release the LogFactory
 */
public static void release(ClassLoader classLoader) {
  if (isDiagnosticsEnabled()) {
    logDiagnostic("Releasing factory for classloader " + objectId(classLoader));
  }
  // factories is not final and could be replaced in this block.
  final Hashtable factories = LogFactory.factories;
  synchronized (factories) {
    if (classLoader == null) {
      if (nullClassLoaderFactory != null) {
        nullClassLoaderFactory.release();
        nullClassLoaderFactory = null;
      }
    } else {
      final LogFactory factory = (LogFactory) factories.get(classLoader);
      if (factory != null) {
        factory.release();
        factories.remove(classLoader);
      }
    }
  }
}

代码示例来源:origin: robovm/robovm

logDiagnostic(
          "[LOOKUP] Properties file found at '" + url + "'"
          + " with priority " + priority); 
          logDiagnostic(
            "[LOOKUP] Properties file at '" + url + "'"
            + " with priority " + newPriority 
      } else {
        if (isDiagnosticsEnabled()) {
          logDiagnostic(
            "[LOOKUP] Properties file at '" + url + "'"
            + " with priority " + newPriority 
  logDiagnostic("SecurityException thrown while trying to find/read config files.");
  logDiagnostic(
    "[LOOKUP] No properties file of name '" + fileName
    + "' found.");
} else {
  logDiagnostic(
    "[LOOKUP] Properties file of name '" + fileName
    + "' found at '" + propsUrl + '"');

代码示例来源:origin: commons-logging/commons-logging

if (LogFactory.class.isAssignableFrom(logFactoryClass)) {
    if (isDiagnosticsEnabled()) {
      logDiagnostic("Loaded class " + logFactoryClass.getName() +
             " from classloader " + objectId(classLoader));
      logDiagnostic("Factory class " + logFactoryClass.getName() +
             " loaded from classloader " + objectId(logFactoryClass.getClassLoader()) +
             " does not extend '" + LogFactory.class.getName() +
      logDiagnostic("Unable to locate any class called '" + factoryClass +
             "' via classloader " + objectId(classLoader));
      logDiagnostic("Class '" + factoryClass + "' cannot be loaded" +
             " via classloader " + objectId(classLoader) +
             " - it depends on some other class that cannot be found.");
      logDiagnostic(msg.toString());
logDiagnostic("Unable to load factory class via classloader " + objectId(classLoader) +
       " - trying the classloader associated with this LogFactory.");
logDiagnostic("Unable to create LogFactory instance.");

代码示例来源:origin: commons-logging/commons-logging

LogConfigurationException ex = (LogConfigurationException) result;
if (isDiagnosticsEnabled()) {
  logDiagnostic("An error occurred while loading the factory class:" + ex.getMessage());
logDiagnostic("Created object " + objectId(result) + " to manage classloader " +
       objectId(contextClassLoader));

代码示例来源:origin: robovm/robovm

/**
 * Release any internal references to previously created {@link LogFactory}
 * instances that have been associated with the specified class loader
 * (if any), after calling the instance method <code>release()</code> on
 * each of them.
 *
 * @param classLoader ClassLoader for which to release the LogFactory
 */
public static void release(ClassLoader classLoader) {
  if (isDiagnosticsEnabled()) {
    logDiagnostic("Releasing factory for classloader " + objectId(classLoader));
  }
  synchronized (factories) {
    if (classLoader == null) {
      if (nullClassLoaderFactory != null) {
        nullClassLoaderFactory.release();
        nullClassLoaderFactory = null;
      }
    } else {
      LogFactory factory = (LogFactory) factories.get(classLoader);
      if (factory != null) {
        factory.release();
        factories.remove(classLoader);
      }
    }
  }
}

代码示例来源:origin: commons-logging/commons-logging

logDiagnostic("Context classloader is null.");
logDiagnostic(
    "[LOOKUP] LogFactory implementation requested for the first time for context classloader " +
    objectId(contextClassLoader));
logDiagnostic("[LOOKUP] Looking for system property [" + FACTORY_PROPERTY +
       "] to define the LogFactory subclass to use...");
if (factoryClass != null) {
  if (isDiagnosticsEnabled()) {
    logDiagnostic("[LOOKUP] Creating an instance of LogFactory class '" + factoryClass +
           "' as specified by system property " + FACTORY_PROPERTY);
} else {
  if (isDiagnosticsEnabled()) {
    logDiagnostic("[LOOKUP] No system property [" + FACTORY_PROPERTY + "] defined.");
  logDiagnostic("[LOOKUP] A security exception occurred while trying to create an" +
         " instance of the custom factory class" + ": [" + trim(e.getMessage()) +
         "]. Trying alternative implementations...");
  logDiagnostic("[LOOKUP] An exception occurred while trying to create an" +
         " instance of the custom factory class" + ": [" +
         trim(e.getMessage()) +
  logDiagnostic("[LOOKUP] Looking for a resource file of name [" + SERVICE_ID +
         "] to define the LogFactory subclass to use...");

代码示例来源:origin: robovm/robovm

LogConfigurationException ex = (LogConfigurationException) result;
if (isDiagnosticsEnabled()) {
  logDiagnostic(
      "An error occurred while loading the factory class:"
      + ex.getMessage());
logDiagnostic(
    "Created object " + objectId(result)
    + " to manage classloader " + objectId(contextClassLoader));

相关文章