org.apache.log4j.spi.LoggerFactory Java Examples
The following examples show how to use
org.apache.log4j.spi.LoggerFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ThreadLocalLogLevelManager.java From olat with Apache License 2.0 | 5 votes |
@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_); } }
Example #2
Source File: Category.java From logging-log4j2 with Apache License 2.0 | 5 votes |
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; }
Example #3
Source File: Category.java From logging-log4j2 with Apache License 2.0 | 5 votes |
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; }
Example #4
Source File: Log4jSyslogBackLogHandler.java From syslog4j-graylog2 with GNU Lesser General Public License v2.1 | 5 votes |
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(); }
Example #5
Source File: Log4jSyslogBackLogHandler.java From syslog4j-graylog2 with GNU Lesser General Public License v2.1 | 5 votes |
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(); }
Example #6
Source File: HaxeDebugLogger.java From intellij-haxe with Apache License 2.0 | 5 votes |
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; }
Example #7
Source File: ThreadLocalLogLevelManager.java From olat with Apache License 2.0 | 5 votes |
/** * 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); } }
Example #8
Source File: ThreadLocalLogLevelManager.java From olat with Apache License 2.0 | 5 votes |
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; }
Example #9
Source File: ThreadLocalLogLevelManager.java From olat with Apache License 2.0 | 5 votes |
/** * 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); } }
Example #10
Source File: ThreadLocalLogLevelManager.java From olat with Apache License 2.0 | 5 votes |
@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_); } }
Example #11
Source File: ThreadLocalLogLevelManager.java From olat with Apache License 2.0 | 5 votes |
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; }
Example #12
Source File: Log4jSyslogBackLogHandler.java From syslog4j with GNU Lesser General Public License v2.1 | 5 votes |
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(); }
Example #13
Source File: Log4jSyslogBackLogHandler.java From syslog4j with GNU Lesser General Public License v2.1 | 5 votes |
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(); }
Example #14
Source File: Hierarchy.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
/** 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. } } }
Example #15
Source File: LogManager.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
/** 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); }
Example #16
Source File: PropertyConfigurator.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
/** 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 + "."); } }
Example #17
Source File: TestLog4Json.java From hadoop with Apache License 2.0 | 4 votes |
@Override public Logger getLogger(String name, LoggerFactory factory) { return new TestLogger(name, this); }
Example #18
Source File: Logger.java From logging-log4j2 with Apache License 2.0 | 4 votes |
public static Logger getLogger(final String name, final LoggerFactory factory) { return Category.getInstance(PrivateManager.getContext(), name, factory); }
Example #19
Source File: LogManager.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@Override public Logger getLogger(final String name, final LoggerFactory factory) { return Category.getInstance(PrivateManager.getContext(), name); }
Example #20
Source File: LogManager.java From logging-log4j2 with Apache License 2.0 | 4 votes |
public static Logger getLogger(final String name, final LoggerFactory factory) { return Category.getInstance(PrivateManager.getContext(), name); }
Example #21
Source File: TestLog4Json.java From big-c with Apache License 2.0 | 4 votes |
@Override public Logger getLogger(String name, LoggerFactory factory) { return new TestLogger(name, this); }
Example #22
Source File: Logger.java From logging-log4j2 with Apache License 2.0 | 4 votes |
public static Logger getLogger(final String name, final LoggerFactory factory) { return Category.getInstance(PrivateManager.getContext(), name, factory); }
Example #23
Source File: LogManager.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@Override public Logger getLogger(final String name, final LoggerFactory factory) { return Category.getInstance(PrivateManager.getContext(), name); }
Example #24
Source File: LogManager.java From logging-log4j2 with Apache License 2.0 | 4 votes |
public static Logger getLogger(final String name, final LoggerFactory factory) { return Category.getInstance(PrivateManager.getContext(), name); }
Example #25
Source File: HaxeDebugLogger.java From intellij-haxe with Apache License 2.0 | 4 votes |
public LoggerFactory getFactory() { return configuredFactory; }
Example #26
Source File: LoggerUtil.java From Bats with Apache License 2.0 | 4 votes |
@Override public Logger getLogger(String name, LoggerFactory factory) { return loggerRepository.getLogger(name, factory); }
Example #27
Source File: LoggerUtil.java From attic-apex-core with Apache License 2.0 | 4 votes |
@Override public Logger getLogger(String name, LoggerFactory factory) { return loggerRepository.getLogger(name, factory); }
Example #28
Source File: Logger.java From cacheonix-core with GNU Lesser General Public License v2.1 | votes |
/** Like {@link #getLogger(String)} except that the type of logger instantiated depends on the type returned by the {@link LoggerFactory#makeNewLoggerInstance} method of the <code>factory</code> parameter. <p>This method is intended to be used by sub-classes. @param name The name of the logger to retrieve. @param factory A {@link LoggerFactory} implementation that will actually create a new Instance. @since 0.8.5 */ public static Logger getLogger(String name, LoggerFactory factory) { return LogManager.getLogger(name, factory); }