@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); } }); }
/** * 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); } }); }
/** * 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); } }); }
/** 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 + "."); } }
/** 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); }
/** 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. } } }
/** 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); } } } } }
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; } }
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(); }
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(); }
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; }
@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_); } }
/** * 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); } }
@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_); } }
/** 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); }
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; }
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; }
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(); }
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(); }
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; }
public static LoggerFactory instance() { return m_instance; }
@Override public Logger getLogger(String name, LoggerFactory factory) { return new TestLogger(name, this); }
@Override public Logger getLogger(String name, LoggerFactory factory) { return loggerRepository.getLogger(name, factory); }
public static Logger getLogger(String name, LoggerFactory loggerFactory) { return Log4jLoggerFactory.getLogger(name, loggerFactory); }