org.apache.log4j.Hierarchy.getLogger()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(174)

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

Hierarchy.getLogger介绍

[英]Return a new logger instance named as the first parameter using the default factory.

If a logger of that name already exists, then it will be returned. Otherwise, a new logger will be instantiated and then linked with its existing ancestors as well as children.
[中]使用默认工厂返回名为第一个参数的新记录器实例。
如果该名称的记录器已存在,则将返回它。否则,将实例化一个新的记录器,然后将其链接到现有的祖先和子级。

代码示例

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

/**
  Return a new logger instance named as the first parameter using
  the default factory.
  <p>If a logger of that name already exists, then it will be
  returned.  Otherwise, a new logger will be instantiated and
  then linked with its existing ancestors as well as children.
  @param name The name of the logger to retrieve.
*/
public
Logger getLogger(String name) {
 return getLogger(name, defaultFactory);
}

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

/**
  Return a new logger instance named as the first parameter using
  the default factory.
  <p>If a logger of that name already exists, then it will be
  returned.  Otherwise, a new logger will be instantiated and
  then linked with its existing ancestors as well as children.
  @param name The name of the logger to retrieve.
*/
public
Logger getLogger(String name) {
 return getLogger(name, defaultFactory);
}

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

/**
  Return a new logger instance named as the first parameter using
  the default factory.
  <p>If a logger of that name already exists, then it will be
  returned.  Otherwise, a new logger will be instantiated and
  then linked with its existing ancestors as well as children.
  @param name The name of the logger to retrieve.
*/
public
Logger getLogger(String name) {
 return getLogger(name, defaultFactory);
}

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

/**
  Return a new logger instance named as the first parameter using
  the default factory.
  <p>If a logger of that name already exists, then it will be
  returned.  Otherwise, a new logger will be instantiated and
  then linked with its existing ancestors as well as children.
  @param name The name of the logger to retrieve.
*/
public
Logger getLogger(String name) {
 return getLogger(name, defaultFactory);
}

代码示例来源:origin: org.apache.activemq/activemq-all

/**
  Return a new logger instance named as the first parameter using
  the default factory.
  <p>If a logger of that name already exists, then it will be
  returned.  Otherwise, a new logger will be instantiated and
  then linked with its existing ancestors as well as children.
  @param name The name of the logger to retrieve.
*/
public
Logger getLogger(String name) {
 return getLogger(name, defaultFactory);
}

代码示例来源:origin: apache-log4j/log4j

/**
  Return a new logger instance named as the first parameter using
  the default factory.
  <p>If a logger of that name already exists, then it will be
  returned.  Otherwise, a new logger will be instantiated and
  then linked with its existing ancestors as well as children.
  @param name The name of the logger to retrieve.
*/
public
Logger getLogger(String name) {
 return getLogger(name, defaultFactory);
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
  Return a new logger instance named as the first parameter using
  the default factory.
  <p>If a logger of that name already exists, then it will be
  returned.  Otherwise, a new logger will be instantiated and
  then linked with its existing ancestors as well as children.
  @param name The name of the logger to retrieve.
*/
public
Logger getLogger(String name) {
 return getLogger(name, defaultFactory);
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.log4j

/**
  Return a new logger instance named as the first parameter using
  the default factory.
  <p>If a logger of that name already exists, then it will be
  returned.  Otherwise, a new logger will be instantiated and
  then linked with its existing ancestors as well as children.
  @param name The name of the logger to retrieve.
*/
public
Logger getLogger(String name) {
 return getLogger(name, defaultFactory);
}

代码示例来源:origin: org.apache/log4j

/**
  Return a new logger instance named as the first parameter using
  the default factory.
  <p>If a logger of that name already exists, then it will be
  returned.  Otherwise, a new logger will be instantiated and
  then linked with its existing ancestors as well as children.
  @param name The name of the logger to retrieve.
*/
public
Logger getLogger(String name) {
 return getLogger(name, defaultFactory);
}

代码示例来源:origin: org.jboss.logmanager/log4j-jboss-logmanager

@Override
public Logger getLogger(String name) {
  return getLogger(name, defaultFactory);
}

代码示例来源:origin: com.ironoreserver/com.ironoreserver.common

protected org.apache.log4j.Logger getLogger() {
  populateMDC();
  return defaultHierarchy.getLogger(name);
}

代码示例来源:origin: com.ironoreserver/com.ironoreserver.common

protected void populateMDC() {
  ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
  if (classLoader != null) {
    if (classLoader.getClass().getName().equalsIgnoreCase("com.ironore.core.WebAppClassLoader")) {
      Method method = null;
      try {
        method = classLoader.getClass().getDeclaredMethod("contextPath");
        method.setAccessible(true);
        Object contextPath = method.invoke(classLoader);
        MDC.put("ironore_contextPath", contextPath);
      } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
        defaultHierarchy.getLogger(Logger.class.getName()).error("unable to get context path through reflection", e);
      }
      return;
    }
  }
  MDC.put("ironore_contextPath", "server");
}

代码示例来源:origin: org.apache.portals.jetspeed-2/jetspeed-webapp-logging

public static void setHierarchy(Hierarchy hierarchy)
{
  synchronized (IsolatedLog4JLogger.class)
  {
    if ( IsolatedLog4JLogger.hierarchy == null )
    {
      IsolatedLog4JLogger.hierarchy = hierarchy;
      if ( notIsolatedLoggers.size() > 0 )
      {
        // Reroute existing IsolatedLog4JLogger instances
        // which were created before the new LoggerRepository.
        // Note: This situation should be prevented as much as
        //       possible by calling setHierarchy from
        //       a ServletContextListener or a Servlet its init method
        //       which has a load-on-startup value of 0 (zero).
        Iterator iter = notIsolatedLoggers.entrySet().iterator();
        while (iter.hasNext())
        {
          Map.Entry entry = (Map.Entry)iter.next();
          IsolatedLog4JLogger logger = (IsolatedLog4JLogger)entry.getKey();
          logger.setLogger(new Log4JLogger(hierarchy.getLogger((String)entry.getValue())));
        }
      }
      notIsolatedLoggers = null;
    }
  }
}

代码示例来源:origin: org.apache.portals.jetspeed-2/jetspeed-webapp-logging

public IsolatedLog4JLogger(String name)
{
  synchronized (IsolatedLog4JLogger.class)
  {
    if ( hierarchy == null )
    {
      // A LogFactory.getLog(name) is called before
      // our ContextClassLoader Hierarchy could be set.
      // Temporarily save this instance so it can be
      // rerouted one the Hierarchy is set.
      logger = new Log4JLogger(name);
      notIsolatedLoggers.put(this,name);
    }
    else
    {
      logger = new Log4JLogger(hierarchy.getLogger(name));               
    }
  }
}

相关文章