Java 类org.apache.log4j.spi.LoggerFactory 实例源码

项目:teamcity-torrent-plugin    文件:AgentTorrentsManager.java   
@Override
public void agentStarted(@NotNull BuildAgent agent) {
  checkReady();
  try {
    startSeeder();
  } catch (IOException e) {
    LOG.warnAndDebugDetails("error start seeder on agent started", e);
  }

  LogManager.getLogger("com.turn.ttorrent", new LoggerFactory() {
    @Override
    public org.apache.log4j.Logger makeNewLoggerInstance(String s) {
      return org.apache.log4j.Logger.getLogger(Loggers.AGENT_CATEGORY);
    }
  });
}
项目:lonline_for_java    文件:Lonline.java   
/**
 * Returns a Lonline logger according className
 *
 * @param className className
 * @return Lonline logger
 */
static public Lonline getLogger(String className) {
    return (Lonline) LogManager.getLogger(className, new LoggerFactory() {
        @Override
        public Logger makeNewLoggerInstance(String name) {
            return new Lonline(name);
        }
    });
}
项目:lonline_for_java    文件:Lonline.java   
/**
 * Returns a Lonline logger according clazz object
 *
 * @param clazz clazz object
 * @return Lonline logger
 */
static public Lonline getLogger(Class clazz) {
    return (Lonline) LogManager.getLogger(clazz.getName(), new LoggerFactory() {
        @Override
        public Logger makeNewLoggerInstance(String name) {
            return new Lonline(name);
        }
    });
}
项目:cacheonix-core    文件:PropertyConfigurator.java   
/**
   Check the provided <code>Properties</code> object for a
   {@link org.apache.log4j.spi.LoggerFactory LoggerFactory}
   entry specified by {@link #LOGGER_FACTORY_KEY}.  If such an entry
   exists, an attempt is made to create an instance using the default
   constructor.  This instance is used for subsequent Category creations
   within this configurator.

   @see #parseCatsAndRenderers
 */
protected void configureLoggerFactory(Properties props) {
  String factoryClassName = OptionConverter.findAndSubst(LOGGER_FACTORY_KEY,
                       props);
  if(factoryClassName != null) {
    LogLog.debug("Setting category factory to ["+factoryClassName+"].");
    loggerFactory = (LoggerFactory)
         OptionConverter.instantiateByClassName(factoryClassName,
                     LoggerFactory.class,
                     loggerFactory);
    PropertySetter.setProperties(loggerFactory, props, FACTORY_PREFIX + ".");
  }
}
项目:cacheonix-core    文件:LogManager.java   
/**
   Retrieve the appropriate {@link Logger} instance.  
*/
public
static 
Logger getLogger(final String name, final LoggerFactory factory) {
   // Delegate the actual manufacturing of the logger to the logger repository.
  return getLoggerRepository().getLogger(name, factory);
}
项目:cacheonix-core    文件:Hierarchy.java   
/**
    Return a new logger instance named as the first parameter using
    <code>factory</code>.

    <p>If a logger of that name already exists, then it will be
    returned.  Otherwise, a new logger will be instantiated by the
    <code>factory</code> parameter and linked with its existing
    ancestors as well as children.

    @param name The name of the logger to retrieve.
    @param factory The factory that will make the new logger instance.

*/
 public
 Logger getLogger(String name, LoggerFactory factory) {
   //System.out.println("getInstance("+name+") called.");
   CategoryKey key = new CategoryKey(name);
   // Synchronize to prevent write conflicts. Read conflicts (in
   // getChainedLevel method) are possible only if variable
   // assignments are non-atomic.
   Logger logger;

   synchronized(ht) {
     Object o = ht.get(key);
     if(o == null) {
logger = factory.makeNewLoggerInstance(name);
logger.setHierarchy(this);
ht.put(key, logger);
updateParents(logger);
return logger;
     } else if(o instanceof Logger) {
return (Logger) o;
     } else if (o instanceof ProvisionNode) {
//System.out.println("("+name+") ht.get(this) returned ProvisionNode");
logger = factory.makeNewLoggerInstance(name);
logger.setHierarchy(this);
ht.put(key, logger);
updateChildren((ProvisionNode) o, logger);
updateParents(logger);
return logger;
     }
     else {
// It should be impossible to arrive here
return null;  // but let's keep the compiler happy.
     }
   }
 }
项目:cacheonix-core    文件:DOMConfigurator.java   
/**
    Used internally to parse the category factory element.
 */
 protected
 void parseCategoryFactory(Element factoryElement) {
   String className = subst(factoryElement.getAttribute(CLASS_ATTR));

   if(EMPTY_STR.equals(className)) {
     LogLog.error("Category Factory tag " + CLASS_ATTR + " attribute not found.");
     LogLog.debug("No Category Factory configured.");
   }
   else {
     LogLog.debug("Desired category factory: ["+className+']');
     Object factory = OptionConverter.instantiateByClassName(className,
                                                                LoggerFactory.class, 
                                                                null);
     if (factory instanceof LoggerFactory) {
         catFactory = (LoggerFactory) factory;
     } else {
         LogLog.error("Category Factory class " + className + " does not implement org.apache.log4j.LoggerFactory");
     }
     PropertySetter propSetter = new PropertySetter(factory);

     Element  currentElement = null;
     Node     currentNode    = null;
     NodeList children       = factoryElement.getChildNodes();
     final int length        = children.getLength();

     for (int loop=0; loop < length; loop++) {
       currentNode = children.item(loop);
if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
  currentElement = (Element)currentNode;
  if (currentElement.getTagName().equals(PARAM_TAG)) {
    setParameter(currentElement, propSetter);
  } else {
          quietParseUnrecognizedElement(factory, currentElement, props);
     }
}
     }
   }
 }
项目:bartleby    文件:Log4jLoggerFactory.java   
public static Logger getLogger(String name, LoggerFactory loggerFactory) {
    org.apache.log4j.Logger instance = log4jLoggers.get(name);
    if (instance != null) {
        return instance;
    } else {
        Logger newInstance = loggerFactory.makeNewLoggerInstance(name);
        Logger oldInstance = log4jLoggers.putIfAbsent(name, newInstance);
        return oldInstance == null ? newInstance : oldInstance;
    }
}
项目:syslog4j    文件:Log4jSyslogBackLogHandler.java   
public Log4jSyslogBackLogHandler(String loggerName, LoggerFactory loggerFactory) {
    if (loggerName == null) {
        throw new SyslogRuntimeException("loggerName cannot be null");
    }

    if (loggerFactory == null) {
        throw new SyslogRuntimeException("loggerFactory cannot be null");
    }

    this.logger = Logger.getLogger(loggerName,loggerFactory);

    initialize();
}
项目:syslog4j    文件:Log4jSyslogBackLogHandler.java   
public Log4jSyslogBackLogHandler(String loggerName, LoggerFactory loggerFactory, boolean appendReason) {
    if (loggerName == null) {
        throw new SyslogRuntimeException("loggerName cannot be null");
    }

    if (loggerFactory == null) {
        throw new SyslogRuntimeException("loggerFactory cannot be null");
    }

    this.logger = Logger.getLogger(loggerName,loggerFactory);
    this.appendReason = appendReason;

    initialize();
}
项目:daq-eclipse    文件:PropertyConfigurator.java   
/**
   Check the provided <code>Properties</code> object for a
   {@link org.apache.log4j.spi.LoggerFactory LoggerFactory}
   entry specified by {@link #LOGGER_FACTORY_KEY}.  If such an entry
   exists, an attempt is made to create an instance using the default
   constructor.  This instance is used for subsequent Category creations
   within this configurator.

   @see #parseCatsAndRenderers
 */
protected void configureLoggerFactory(Properties props) {
  String factoryClassName = OptionConverter.findAndSubst(LOGGER_FACTORY_KEY,
                       props);
  if(factoryClassName != null) {
    LogLog.debug("Setting category factory to ["+factoryClassName+"].");
    loggerFactory = (LoggerFactory)
         OptionConverter.instantiateByClassName(factoryClassName,
                     LoggerFactory.class,
                     loggerFactory);
    PropertySetter.setProperties(loggerFactory, props, FACTORY_PREFIX + ".");
  }
}
项目:daq-eclipse    文件:LogManager.java   
/**
   Retrieve the appropriate {@link Logger} instance.  
*/
public
static 
Logger getLogger(final String name, final LoggerFactory factory) {
   // Delegate the actual manufacturing of the logger to the logger repository.
  return getLoggerRepository().getLogger(name, factory);
}
项目:daq-eclipse    文件:Hierarchy.java   
/**
    Return a new logger instance named as the first parameter using
    <code>factory</code>.

    <p>If a logger of that name already exists, then it will be
    returned.  Otherwise, a new logger will be instantiated by the
    <code>factory</code> parameter and linked with its existing
    ancestors as well as children.

    @param name The name of the logger to retrieve.
    @param factory The factory that will make the new logger instance.

*/
 public
 Logger getLogger(String name, LoggerFactory factory) {
   //System.out.println("getInstance("+name+") called.");
   CategoryKey key = new CategoryKey(name);
   // Synchronize to prevent write conflicts. Read conflicts (in
   // getChainedLevel method) are possible only if variable
   // assignments are non-atomic.
   Logger logger;

   synchronized(ht) {
     Object o = ht.get(key);
     if(o == null) {
logger = factory.makeNewLoggerInstance(name);
logger.setHierarchy(this);
ht.put(key, logger);
updateParents(logger);
return logger;
     } else if(o instanceof Logger) {
return (Logger) o;
     } else if (o instanceof ProvisionNode) {
//System.out.println("("+name+") ht.get(this) returned ProvisionNode");
logger = factory.makeNewLoggerInstance(name);
logger.setHierarchy(this);
ht.put(key, logger);
updateChildren((ProvisionNode) o, logger);
updateParents(logger);
return logger;
     }
     else {
// It should be impossible to arrive here
return null;  // but let's keep the compiler happy.
     }
   }
 }
项目:daq-eclipse    文件:DOMConfigurator.java   
/**
    Used internally to parse the category factory element.
 */
 protected
 void parseCategoryFactory(Element factoryElement) {
   String className = subst(factoryElement.getAttribute(CLASS_ATTR));

   if(EMPTY_STR.equals(className)) {
     LogLog.error("Category Factory tag " + CLASS_ATTR + " attribute not found.");
     LogLog.debug("No Category Factory configured.");
   }
   else {
     LogLog.debug("Desired category factory: ["+className+']');
     Object factory = OptionConverter.instantiateByClassName(className,
                                                                LoggerFactory.class, 
                                                                null);
     if (factory instanceof LoggerFactory) {
         catFactory = (LoggerFactory) factory;
     } else {
         LogLog.error("Category Factory class " + className + " does not implement org.apache.log4j.LoggerFactory");
     }
     PropertySetter propSetter = new PropertySetter(factory);

     Element  currentElement = null;
     Node     currentNode    = null;
     NodeList children       = factoryElement.getChildNodes();
     final int length        = children.getLength();

     for (int loop=0; loop < length; loop++) {
       currentNode = children.item(loop);
if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
  currentElement = (Element)currentNode;
  if (currentElement.getTagName().equals(PARAM_TAG)) {
    setParameter(currentElement, propSetter);
  } else {
          quietParseUnrecognizedElement(factory, currentElement, props);
     }
}
     }
   }
 }
项目:olat    文件:ThreadLocalLogLevelManager.java   
public ThreadLocalAwareLoggerRepository(Logger originalRoot, LoggerRepository parentRepository, LoggerFactory loggerFactory) {
    super(originalRoot);
    if (loggerFactory == null) {
        throw new IllegalArgumentException("loggerFactory must not be null");
    }
    loggerFactory_ = loggerFactory;

    parentLoggerRepository_ = parentRepository;
}
项目:olat    文件:ThreadLocalLogLevelManager.java   
@Override
public Logger getLogger(String name, @SuppressWarnings("unused") LoggerFactory factory) {
    Logger existingLogger = parentLoggerRepository_.exists(name);
    if (existingLogger != null) {
        // Returning the original logger here - note that this will prevent certain loggers from being
        // taken under ThreadLocalAwareLogger's control - hence any logger created before
        // ThreadLocalLogLevelManager.install() will not be redirected!
        return existingLogger;
    } else {
        return super.getLogger(name, loggerFactory_);
    }
}
项目:olat    文件:ThreadLocalLogLevelManager.java   
/**
 * Installs the ThreadLogManager in this system.
 * <p>
 * Note that this can fail if some other framework has done a call to LogManager.setRepositorySelector with a guard already.
 * 
 * @param logMessageModifier
 *            optional implementation of LogMessageModifier which allows messages to be modified should they be affected by a threadlocal loglevel overwrite. This
 *            allows for example for messages to be prepended with a token so that they can be easier found in the log
 */
void install(final LogMessageModifier logMessageModifier) {

    try {
        final LoggerFactory loggerFactory = new LoggerFactory() {

            @SuppressWarnings("synthetic-access")
            @Override
            public Logger makeNewLoggerInstance(String name) {
                return new ThreadLocalAwareLogger(name, threadLocalLogLevel_, logMessageModifier);
            }
        };

        final Logger originalRootLogger = LogManager.getRootLogger();

        final LoggerRepository parentRepository = originalRootLogger.getLoggerRepository();

        final LoggerRepository repository = new ThreadLocalAwareLoggerRepository(originalRootLogger, parentRepository, loggerFactory);

        LogManager.setRepositorySelector(new RepositorySelector() {

            @Override
            public LoggerRepository getLoggerRepository() {
                return repository;
            }
        }, guard);
    } catch (IllegalArgumentException re) {
        // thrown by LogManager.setRepositorySelector
        log.error("Could not install ThreadLocalLogLevelManager", re);
    }

}
项目:olat    文件:ThreadLocalLogLevelManager.java   
public ThreadLocalAwareLoggerRepository(Logger originalRoot, LoggerRepository parentRepository, LoggerFactory loggerFactory) {
    super(originalRoot);
    if (loggerFactory == null) {
        throw new IllegalArgumentException("loggerFactory must not be null");
    }
    loggerFactory_ = loggerFactory;

    parentLoggerRepository_ = parentRepository;
}
项目:olat    文件:ThreadLocalLogLevelManager.java   
@Override
public Logger getLogger(String name, LoggerFactory factory) {
    Logger existingLogger = parentLoggerRepository_.exists(name);
    if (existingLogger != null) {
        // Returning the original logger here - note that this will prevent certain loggers from being
        // taken under ThreadLocalAwareLogger's control - hence any logger created before
        // ThreadLocalLogLevelManager.install() will not be redirected!
        return existingLogger;
    } else {
        return super.getLogger(name, loggerFactory_);
    }
}
项目:olat    文件:ThreadLocalLogLevelManager.java   
/**
 * Installs the ThreadLogManager in this system.
 * <p>
 * Note that this can fail if some other framework has done a call to LogManager.setRepositorySelector with a guard already.
 * 
 * @param logMessageModifier
 *            optional implementation of LogMessageModifier which allows messages to be modified should they be affected by a threadlocal loglevel overwrite. This
 *            allows for example for messages to be prepended with a token so that they can be easier found in the log
 */
void install(final LogMessageModifier logMessageModifier) {

    try {
        final LoggerFactory loggerFactory = new LoggerFactory() {

            @SuppressWarnings("synthetic-access")
            @Override
            public Logger makeNewLoggerInstance(String name) {
                return new ThreadLocalAwareLogger(name, threadLocalLogLevel_, logMessageModifier);
            }
        };

        final Logger originalRootLogger = LogManager.getRootLogger();

        final LoggerRepository parentRepository = originalRootLogger.getLoggerRepository();

        final LoggerRepository repository = new ThreadLocalAwareLoggerRepository(originalRootLogger, parentRepository, loggerFactory);

        LogManager.setRepositorySelector(new RepositorySelector() {

            @Override
            public LoggerRepository getLoggerRepository() {
                return repository;
            }
        }, guard);
    } catch (IllegalArgumentException re) {
        // thrown by LogManager.setRepositorySelector
        log.error("Could not install ThreadLocalLogLevelManager", re);
    }

}
项目:nabs    文件:PropertyConfigurator.java   
/**
   Check the provided <code>Properties</code> object for a
   {@link org.apache.log4j.spi.LoggerFactory LoggerFactory}
   entry specified by {@link #LOGGER_FACTORY_KEY}.  If such an entry
   exists, an attempt is made to create an instance using the default
   constructor.  This instance is used for subsequent Category creations
   within this configurator.

   @see #parseCatsAndRenderers
 */
protected void configureLoggerFactory(Properties props) {
  String factoryClassName = OptionConverter.findAndSubst(LOGGER_FACTORY_KEY,
                       props);
  if(factoryClassName != null) {
    LogLog.debug("Setting category factory to ["+factoryClassName+"].");
    loggerFactory = (LoggerFactory)
         OptionConverter.instantiateByClassName(factoryClassName,
                     LoggerFactory.class,
                     loggerFactory);
    PropertySetter.setProperties(loggerFactory, props, FACTORY_PREFIX + ".");
  }
}
项目:nabs    文件:LogManager.java   
/**
   Retrieve the appropriate {@link Logger} instance.  
*/
public
static 
Logger getLogger(String name, LoggerFactory factory) {
   // Delegate the actual manufacturing of the logger to the logger repository.
  return repositorySelector.getLoggerRepository().getLogger(name, factory);
}
项目:nabs    文件:Hierarchy.java   
/**
    Return a new logger instance named as the first parameter using
    <code>factory</code>.

    <p>If a logger of that name already exists, then it will be
    returned.  Otherwise, a new logger will be instantiated by the
    <code>factory</code> parameter and linked with its existing
    ancestors as well as children.

    @param name The name of the logger to retrieve.
    @param factory The factory that will make the new logger instance.

*/
 public
 Logger getLogger(String name, LoggerFactory factory) {
   //System.out.println("getInstance("+name+") called.");
   CategoryKey key = new CategoryKey(name);
   // Synchronize to prevent write conflicts. Read conflicts (in
   // getChainedLevel method) are possible only if variable
   // assignments are non-atomic.
   Logger logger;

   synchronized(ht) {
     Object o = ht.get(key);
     if(o == null) {
logger = factory.makeNewLoggerInstance(name);
logger.setHierarchy(this);
ht.put(key, logger);
updateParents(logger);
return logger;
     } else if(o instanceof Logger) {
return (Logger) o;
     } else if (o instanceof ProvisionNode) {
//System.out.println("("+name+") ht.get(this) returned ProvisionNode");
logger = factory.makeNewLoggerInstance(name);
logger.setHierarchy(this);
ht.put(key, logger);
updateChildren((ProvisionNode) o, logger);
updateParents(logger);
return logger;
     }
     else {
// It should be impossible to arrive here
return null;  // but let's keep the compiler happy.
     }
   }
 }
项目:jretty-log    文件:Log4jLoggerFactory.java   
public static Logger getLogger(String name, LoggerFactory loggerFactory) {
    org.apache.log4j.Logger instance = log4jLoggers.get(name);
    if (instance != null) {
        return instance;
    } else {
        Logger newInstance = loggerFactory.makeNewLoggerInstance(name);
        Logger oldInstance = log4jLoggers.putIfAbsent(name, newInstance);
        return oldInstance == null ? newInstance : oldInstance;
    }
}
项目:intellij-haxe    文件:HaxeDebugLogger.java   
public static HaxeDebugLogger getLogger(String name, LoggerFactory factory) {
  Logger logger = manager.getHierarchy().getLogger(name, factory);
  assert(logger instanceof HaxeDebugLogger);
  if (manager.getLogConfiguration().contains(name)) {
    logger.setLevel(manager.getLogConfiguration().getLevel(name));
  } else {
    manager.getLogConfiguration().addConfiguration(name, manager.getDefaultLevel());
    logger.setLevel(manager.getDefaultLevel());
  }
  logger.addAppender(manager.getDefaultAppender());
  return (HaxeDebugLogger)logger;
}
项目:log4j2    文件:Category.java   
static Category getInstance(final LoggerContext context, final String name, final LoggerFactory factory) {
    final ConcurrentMap<String, Logger> loggers = getLoggersMap(context);
    Logger logger = loggers.get(name);
    if (logger != null) {
        return logger;
    }
    logger = factory.makeNewLoggerInstance(context, name);
    final Logger prev = loggers.putIfAbsent(name, logger);
    return prev == null ? logger : prev;
}
项目:syslog4j-graylog2    文件:Log4jSyslogBackLogHandler.java   
public Log4jSyslogBackLogHandler(String loggerName, LoggerFactory loggerFactory) {
    if (loggerName == null) {
        throw new SyslogRuntimeException("loggerName cannot be null");
    }

    if (loggerFactory == null) {
        throw new SyslogRuntimeException("loggerFactory cannot be null");
    }

    this.logger = Logger.getLogger(loggerName, loggerFactory);

    initialize();
}
项目:syslog4j-graylog2    文件:Log4jSyslogBackLogHandler.java   
public Log4jSyslogBackLogHandler(String loggerName, LoggerFactory loggerFactory, boolean appendReason) {
    if (loggerName == null) {
        throw new SyslogRuntimeException("loggerName cannot be null");
    }

    if (loggerFactory == null) {
        throw new SyslogRuntimeException("loggerFactory cannot be null");
    }

    this.logger = Logger.getLogger(loggerName, loggerFactory);
    this.appendReason = appendReason;

    initialize();
}
项目:logging-log4j2    文件:Category.java   
static Logger getInstance(final LoggerContext context, final String name, final LoggerFactory factory) {
    final ConcurrentMap<String, Logger> loggers = getLoggersMap(context);
    Logger logger = loggers.get(name);
    if (logger != null) {
        return logger;
    }
    logger = factory.makeNewLoggerInstance(name);
    final Logger prev = loggers.putIfAbsent(name, logger);
    return prev == null ? logger : prev;
}
项目:sstore-soft    文件:VoltLoggerFactory.java   
public static LoggerFactory instance() {
    return m_instance;
}
项目:hadoop-oss    文件:TestLog4Json.java   
@Override
public Logger getLogger(String name, LoggerFactory factory) {
  return new TestLogger(name, this);
}
项目:s-store    文件:VoltLoggerFactory.java   
public static LoggerFactory instance() {
    return m_instance;
}
项目:hadoop    文件:TestLog4Json.java   
@Override
public Logger getLogger(String name, LoggerFactory factory) {
  return new TestLogger(name, this);
}
项目:aliyun-oss-hadoop-fs    文件:TestLog4Json.java   
@Override
public Logger getLogger(String name, LoggerFactory factory) {
  return new TestLogger(name, this);
}
项目:big-c    文件:TestLog4Json.java   
@Override
public Logger getLogger(String name, LoggerFactory factory) {
  return new TestLogger(name, this);
}
项目:apex-core    文件:LoggerUtil.java   
@Override
public Logger getLogger(String name, LoggerFactory factory)
{
  return loggerRepository.getLogger(name, factory);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestLog4Json.java   
@Override
public Logger getLogger(String name, LoggerFactory factory) {
  return new TestLogger(name, this);
}
项目:bartleby    文件:Logger.java   
public static Logger getLogger(String name, LoggerFactory loggerFactory) {
    return Log4jLoggerFactory.getLogger(name, loggerFactory);
}
项目:hadoop-plus    文件:TestLog4Json.java   
@Override
public Logger getLogger(String name, LoggerFactory factory) {
  return new TestLogger(name, this);
}
项目:hops    文件:TestLog4Json.java   
@Override
public Logger getLogger(String name, LoggerFactory factory) {
  return new TestLogger(name, this);
}