當前位置: 首頁>>代碼示例>>Java>>正文


Java LoggerFactory類代碼示例

本文整理匯總了Java中org.apache.log4j.spi.LoggerFactory的典型用法代碼示例。如果您正苦於以下問題:Java LoggerFactory類的具體用法?Java LoggerFactory怎麽用?Java LoggerFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LoggerFactory類屬於org.apache.log4j.spi包,在下文中一共展示了LoggerFactory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: agentStarted

import org.apache.log4j.spi.LoggerFactory; //導入依賴的package包/類
@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);
    }
  });
}
 
開發者ID:JetBrains,項目名稱:teamcity-torrent-plugin,代碼行數:17,代碼來源:AgentTorrentsManager.java

示例2: getLogger

import org.apache.log4j.spi.LoggerFactory; //導入依賴的package包/類
/**
 * 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);
        }
    });
}
 
開發者ID:egomezr,項目名稱:lonline_for_java,代碼行數:15,代碼來源:Lonline.java

示例3: configureLoggerFactory

import org.apache.log4j.spi.LoggerFactory; //導入依賴的package包/類
/**
   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 + ".");
  }
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:23,代碼來源:PropertyConfigurator.java

示例4: getLogger

import org.apache.log4j.spi.LoggerFactory; //導入依賴的package包/類
/**
   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);
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:10,代碼來源:LogManager.java

示例5: getLogger

import org.apache.log4j.spi.LoggerFactory; //導入依賴的package包/類
/**
    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.
     }
   }
 }
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:48,代碼來源:Hierarchy.java

示例6: parseCategoryFactory

import org.apache.log4j.spi.LoggerFactory; //導入依賴的package包/類
/**
    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);
     }
}
     }
   }
 }
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:42,代碼來源:DOMConfigurator.java

示例7: getLogger

import org.apache.log4j.spi.LoggerFactory; //導入依賴的package包/類
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;
    }
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:11,代碼來源:Log4jLoggerFactory.java

示例8: Log4jSyslogBackLogHandler

import org.apache.log4j.spi.LoggerFactory; //導入依賴的package包/類
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();
}
 
開發者ID:syslog4j,項目名稱:syslog4j,代碼行數:14,代碼來源:Log4jSyslogBackLogHandler.java

示例9: ThreadLocalAwareLoggerRepository

import org.apache.log4j.spi.LoggerFactory; //導入依賴的package包/類
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;
}
 
開發者ID:huihoo,項目名稱:olat,代碼行數:10,代碼來源:ThreadLocalLogLevelManager.java

示例10: getLogger

import org.apache.log4j.spi.LoggerFactory; //導入依賴的package包/類
@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_);
    }
}
 
開發者ID:huihoo,項目名稱:olat,代碼行數:13,代碼來源:ThreadLocalLogLevelManager.java

示例11: install

import org.apache.log4j.spi.LoggerFactory; //導入依賴的package包/類
/**
 * 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);
    }

}
 
開發者ID:huihoo,項目名稱:olat,代碼行數:41,代碼來源:ThreadLocalLogLevelManager.java

示例12: getLogger

import org.apache.log4j.spi.LoggerFactory; //導入依賴的package包/類
@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_);
    }
}
 
開發者ID:huihoo,項目名稱:olat,代碼行數:13,代碼來源:ThreadLocalLogLevelManager.java

示例13: getLogger

import org.apache.log4j.spi.LoggerFactory; //導入依賴的package包/類
/**
   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);
}
 
開發者ID:nologic,項目名稱:nabs,代碼行數:10,代碼來源:LogManager.java

示例14: getLogger

import org.apache.log4j.spi.LoggerFactory; //導入依賴的package包/類
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;
}
 
開發者ID:HaxeFoundation,項目名稱:intellij-haxe,代碼行數:13,代碼來源:HaxeDebugLogger.java

示例15: getInstance

import org.apache.log4j.spi.LoggerFactory; //導入依賴的package包/類
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;
}
 
開發者ID:OuZhencong,項目名稱:log4j2,代碼行數:11,代碼來源:Category.java


注:本文中的org.apache.log4j.spi.LoggerFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。