本文整理了Java中org.apache.log4j.spi.LoggerFactory
类的一些代码示例,展示了LoggerFactory
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LoggerFactory
类的具体详情如下:
包路径:org.apache.log4j.spi.LoggerFactory
类名称:LoggerFactory
[英]Implement this interface to create new instances of Logger or a sub-class of Logger.
See examples/subclass/MyLogger.java
for an example.
[中]实现此接口以创建记录器的新实例或记录器的子类。
有关示例,请参见examples/subclass/MyLogger.java
。
代码示例来源:origin: org.slf4j/log4j-over-slf4j
/**
* Returns a logger instance created by loggerFactory. This method was requested in
* <a href="http://jira.qos.ch/browse/SLF4J-225">SLF4J-225</a>. Note that
* log4j-over-slf4j does not ship with a LoggerFactory implementation. If this
* method is called, the caller must provide his/her own implementation.
*
* @param name the name of the desired logger
* @param loggerFactory an instance of {@link LoggerFactory}
* @return returns a logger instance created by loggerFactory
* @since 1.6.6
*/
public static Logger getLogger(String name, LoggerFactory loggerFactory) {
return loggerFactory.makeNewLoggerInstance(name);
}
代码示例来源:origin: org.slf4j/log4j-over-slf4j
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;
}
}
}
代码示例来源:origin: log4j/log4j
Object o = ht.get(key);
if(o == null) {
logger = factory.makeNewLoggerInstance(name);
logger.setHierarchy(this);
ht.put(key, logger);
} else if (o instanceof ProvisionNode) {
logger = factory.makeNewLoggerInstance(name);
logger.setHierarchy(this);
ht.put(key, logger);
代码示例来源:origin: camunda/camunda-bpm-platform
Object o = ht.get(key);
if(o == null) {
logger = factory.makeNewLoggerInstance(name);
logger.setHierarchy(this);
ht.put(key, logger);
} else if (o instanceof ProvisionNode) {
logger = factory.makeNewLoggerInstance(name);
logger.setHierarchy(this);
ht.put(key, logger);
代码示例来源:origin: apache/log4j
Object o = ht.get(key);
if(o == null) {
logger = factory.makeNewLoggerInstance(name);
logger.setHierarchy(this);
ht.put(key, logger);
} else if (o instanceof ProvisionNode) {
logger = factory.makeNewLoggerInstance(name);
logger.setHierarchy(this);
ht.put(key, logger);
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.slf4j.log4j
/**
* Returns a logger instance created by loggerFactory. This method was requested in
* <a href="http://bugzilla.slf4j.org/show_bug.cgi?id=234">bug #234</a>. Note that
* log4j-over-slf4j does not ship with a LoggerFactory implementation. If this
* method is called, the caller must provide his/her own implementation.
*
* @param name the name of the desired logger
* @param loggerFactory an instance of {@link LoggerFactory}
* @return returns a logger instance created by loggerFactory
* @since 1.6.6
*/
public static Logger getLogger(String name, LoggerFactory loggerFactory) {
return loggerFactory.makeNewLoggerInstance(name);
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.slf4j.log4j
public static synchronized Logger getLogger(String name, LoggerFactory loggerFactory) {
if (log4jLoggers.containsKey(name)) {
return (org.apache.log4j.Logger) log4jLoggers.get(name);
} else {
Logger log4jLogger = loggerFactory.makeNewLoggerInstance(name);
log4jLoggers.put(name, log4jLogger);
return log4jLogger;
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-1.2-api
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;
}
代码示例来源:origin: org.apache.logging.log4j.adapters/log4j-1.2-api
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;
}
代码示例来源:origin: stackoverflow.com
69 Hashtable ht;
...
258 public
259 Logger getLogger(String name, LoggerFactory factory) {
260 //System.out.println("getInstance("+name+") called.");
261 CategoryKey key = new CategoryKey(name);
262 // Synchronize to prevent write conflicts. Read conflicts (in
263 // getChainedLevel method) are possible only if variable
264 // assignments are non-atomic.
265 Logger logger;
266
267 synchronized(ht) {
268 Object o = ht.get(key);
269 if(o == null) {
270 logger = factory.makeNewLoggerInstance(name);
271 logger.setHierarchy(this);
272 ht.put(key, logger);
273 updateParents(logger);
274 return logger;
275 } else if(o instanceof Logger) {
276 return (Logger) o;
277 }
...
代码示例来源:origin: org.jmxtrans/jmxtrans-output-log4j
/**
* Initializes the logger. This is called when we need to create a new
* logger for the given file name.
*
* @param fileStr
* @return a new Logger instance for the given fileStr
* @throws IOException
*/
protected Logger initLogger(String fileStr) throws IOException {
PatternLayout pl = new PatternLayout(LOG_PATTERN);
final FileAppender appender = new FileAppender(pl, fileStr, true);
appender.setBufferedIO(false);
appender.setBufferSize(LOG_IO_BUFFER_SIZE_BYTES);
LoggerFactory loggerFactory = new LoggerFactory() {
@Override
public Logger makeNewLoggerInstance(String name) {
Logger logger = Logger.getLogger(name);
logger.addAppender(appender);
logger.setLevel(Level.INFO);
logger.setAdditivity(false);
return logger;
}
};
return loggerFactory.makeNewLoggerInstance("NagiosWriter" + this.hashCode());
}
代码示例来源:origin: org.apache.activemq/activemq-all
Object o = ht.get(key);
if(o == null) {
logger = factory.makeNewLoggerInstance(name);
logger.setHierarchy(this);
ht.put(key, logger);
} else if (o instanceof ProvisionNode) {
logger = factory.makeNewLoggerInstance(name);
logger.setHierarchy(this);
ht.put(key, logger);
代码示例来源:origin: org.apache.log4j/com.springsource.org.apache.log4j
Object o = ht.get(key);
if(o == null) {
logger = factory.makeNewLoggerInstance(name);
logger.setHierarchy(this);
ht.put(key, logger);
} else if (o instanceof ProvisionNode) {
logger = factory.makeNewLoggerInstance(name);
logger.setHierarchy(this);
ht.put(key, logger);
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
Object o = ht.get(key);
if(o == null) {
logger = factory.makeNewLoggerInstance(name);
logger.setHierarchy(this);
ht.put(key, logger);
} else if (o instanceof ProvisionNode) {
logger = factory.makeNewLoggerInstance(name);
logger.setHierarchy(this);
ht.put(key, logger);
代码示例来源:origin: apache-log4j/log4j
Object o = ht.get(key);
if(o == null) {
logger = factory.makeNewLoggerInstance(name);
logger.setHierarchy(this);
ht.put(key, logger);
} else if (o instanceof ProvisionNode) {
logger = factory.makeNewLoggerInstance(name);
logger.setHierarchy(this);
ht.put(key, logger);
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.log4j
Object o = ht.get(key);
if(o == null) {
logger = factory.makeNewLoggerInstance(name);
logger.setHierarchy(this);
ht.put(key, logger);
} else if (o instanceof ProvisionNode) {
logger = factory.makeNewLoggerInstance(name);
logger.setHierarchy(this);
ht.put(key, logger);
代码示例来源:origin: org.apache/log4j
Object o = ht.get(key);
if(o == null) {
logger = factory.makeNewLoggerInstance(name);
logger.setHierarchy(this);
ht.put(key, logger);
} else if (o instanceof ProvisionNode) {
logger = factory.makeNewLoggerInstance(name);
logger.setHierarchy(this);
ht.put(key, logger);
代码示例来源:origin: org.jboss.logmanager/log4j-jboss-logmanager
Logger logger = getLogger(lmLogger);
if (logger == null) {
logger = factory.makeNewLoggerInstance(name);
final Logger currentLogger = attachIfAbsent(lmLogger, LOGGER_KEY, logger);
if (currentLogger != null) {
内容来源于网络,如有侵权,请联系作者删除!