当前位置: 首页>>代码示例>>Java>>正文


Java AbstractLogger类代码示例

本文整理汇总了Java中org.apache.logging.log4j.spi.AbstractLogger的典型用法代码示例。如果您正苦于以下问题:Java AbstractLogger类的具体用法?Java AbstractLogger怎么用?Java AbstractLogger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AbstractLogger类属于org.apache.logging.log4j.spi包,在下文中一共展示了AbstractLogger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLogger

import org.apache.logging.log4j.spi.AbstractLogger; //导入依赖的package包/类
@Override
public Log4jTaglibLogger getLogger(final String name, final MessageFactory factory) {
    Log4jTaglibLogger logger = this.loggers.get(name);
    if (logger != null) {
        AbstractLogger.checkMessageFactory(logger, factory);
        return logger;
    }

    synchronized (this.loggers) {
        logger = this.loggers.get(name);
        if (logger == null) {
            final Logger original = factory == null ?
                    LogManager.getLogger(name) : LogManager.getLogger(name, factory);
            if (!(original instanceof AbstractLogger)) {
                throw new LoggingException(
                        "Log4j Tag Library requires base logging system to extend Log4j AbstractLogger."
                );
            }
            // wrap a logger from an underlying implementation
            logger = new Log4jTaglibLogger((AbstractLogger) original, name, original.getMessageFactory());
            this.loggers.put(name, logger);
        }
    }

    return logger;
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:27,代码来源:Log4jTaglibLoggerContext.java

示例2: resolveLogger

import org.apache.logging.log4j.spi.AbstractLogger; //导入依赖的package包/类
static Log4jTaglibLogger resolveLogger(final Log4jTaglibLoggerContext context, final Object logger,
                                       final MessageFactory factory) throws JspException {
    if (logger instanceof Logger) {
        if (logger instanceof Log4jTaglibLogger) {
            return (Log4jTaglibLogger) logger;
        }
        if (logger instanceof AbstractLogger) {
            if (LOGGER.isInfoEnabled() && !WARNED_FOR.contains(logger)) {
                LOGGER.info("Constructing new Log4jTaglibLogger from AbstractLogger {} name and message factory.",
                        logger.getClass().getName());
                WARNED_FOR.add(logger);
            }
            final AbstractLogger original = (AbstractLogger) logger;
            return getLogger(context, original.getName(), original.getMessageFactory());
        }
        throw new JspException(
                "Log4j Tag Library requires base logging system to extend Log4j AbstractLogger.");
    }
    if (logger instanceof String) {
        return getLogger(context, (String) logger, factory);
    }
    throw new JspException("Logger must be of type String or org.apache.logging.log4j.Logger.");
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:24,代码来源:TagUtils.java

示例3: testGetLoggerWithTaglibLogger

import org.apache.logging.log4j.spi.AbstractLogger; //导入依赖的package包/类
@Test
public void testGetLoggerWithTaglibLogger() throws Exception {
    this.setUp(null);

    final AbstractLogger wrapped = (AbstractLogger)LogManager.getLogger("testGetLoggerWithTaglibLogger");
    final Log4jTaglibLogger logger = new Log4jTaglibLogger(wrapped, wrapped.getName(), wrapped.getMessageFactory());

    this.tag.setLogger(logger);
    Log4jTaglibLogger returned = this.tag.getLogger();

    assertNotNull("The first returned logger should not be null.", returned);
    assertSame("The first returned logger should be the same as the set.", logger, returned);
    assertEquals("The name is not correct.", "testGetLoggerWithTaglibLogger", returned.getName());

    returned = this.tag.getLogger();

    assertNotNull("The second returned logger should not be null.", returned);
    assertSame("The second returned logger should be the same as the set.", logger, returned);
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:20,代码来源:LoggerAwareTagSupportTest.java

示例4: getLogger

import org.apache.logging.log4j.spi.AbstractLogger; //导入依赖的package包/类
@Override
public Logger getLogger(final String name) {
    final LoggerContext context = getContext();
    final ConcurrentMap<String, Logger> loggers = getLoggersMap(context);

    if (loggers.containsKey(name)) {
        return loggers.get(name);
    }
    final String key = Logger.ROOT_LOGGER_NAME.equals(name) ? LogManager.ROOT_LOGGER_NAME : name;
    final org.apache.logging.log4j.Logger logger = context.getLogger(key);
    if (logger instanceof AbstractLogger) {
        loggers.putIfAbsent(name, new SLF4JLogger((AbstractLogger) logger, name));
        return loggers.get(name);
    }
    throw new SLF4JLoggingException("SLF4J Adapter requires base logging system to extend Log4j AbstractLogger");
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:17,代码来源:Log4jLoggerFactory.java

示例5: getLogger

import org.apache.logging.log4j.spi.AbstractLogger; //导入依赖的package包/类
@Override
public Log4jTaglibLogger getLogger(final String name, final MessageFactory messageFactory) {
    // Note: This is the only method where we add entries to the 'loggerRegistry' ivar.
    Log4jTaglibLogger logger = this.loggerRegistry.getLogger(name, messageFactory);
    if (logger != null) {
        AbstractLogger.checkMessageFactory(logger, messageFactory);
        return logger;
    }

    synchronized (this.loggerRegistry) {
        logger = this.loggerRegistry.getLogger(name, messageFactory);
        if (logger == null) {
            final LoggerContext context = LogManager.getContext(false);
            final ExtendedLogger original = messageFactory == null ?
                    context.getLogger(name) : context.getLogger(name, messageFactory);
            // wrap a logger from an underlying implementation
            logger = new Log4jTaglibLogger(original, name, original.getMessageFactory());
            this.loggerRegistry.putIfAbsent(name, messageFactory, logger);
        }
    }

    return logger;
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:24,代码来源:Log4jTaglibLoggerContext.java

示例6: append

import org.apache.logging.log4j.spi.AbstractLogger; //导入依赖的package包/类
/**
 * Actual writing occurs here.
 *
 * @param logEvent The LogEvent.
 */
@Override
public void append(final LogEvent logEvent) {
    if (!isStarted()) {
        throw new IllegalStateException("AsyncAppender " + getName() + " is not active");
    }
    final Log4jLogEvent memento = Log4jLogEvent.createMemento(logEvent, includeLocation);
    InternalAsyncUtil.makeMessageImmutable(logEvent.getMessage());
    if (!transfer(memento)) {
        if (blocking) {
            if (AbstractLogger.getRecursionDepth() > 1) { // LOG4J2-1518, LOG4J2-2031
                // If queue is full AND we are in a recursive call, call appender directly to prevent deadlock
                final Message message = AsyncQueueFullMessageUtil.transform(logEvent.getMessage());
                logMessageInCurrentThread(new Log4jLogEvent.Builder(logEvent).setMessage(message).build());
            } else {
                // delegate to the event router (which may discard, enqueue and block, or log in current thread)
                final EventRoute route = asyncQueueFullPolicy.getRoute(thread.getId(), memento.getLevel());
                route.logMessage(this, memento);
            }
        } else {
            error("Appender " + getName() + " is unable to write primary appenders. queue is full");
            logToErrorAppenderIfNecessary(false, memento);
        }
    }
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:30,代码来源:AsyncAppender.java

示例7: handleRingBufferFull

import org.apache.logging.log4j.spi.AbstractLogger; //导入依赖的package包/类
private void handleRingBufferFull(final RingBufferLogEventTranslator translator) {
    if (AbstractLogger.getRecursionDepth() > 1) { // LOG4J2-1518, LOG4J2-2031
        // If queue is full AND we are in a recursive call, call appender directly to prevent deadlock
        final Message message = AsyncQueueFullMessageUtil.transform(translator.message);
        logMessageInCurrentThread(translator.fqcn, translator.level, translator.marker, message,
                translator.thrown);
        return;
    }
    final EventRoute eventRoute = loggerDisruptor.getEventRoute(translator.level);
    switch (eventRoute) {
        case ENQUEUE:
            loggerDisruptor.enqueueLogMessageInfo(translator);
            break;
        case SYNCHRONOUS:
            logMessageInCurrentThread(translator.fqcn, translator.level, translator.marker, translator.message,
                    translator.thrown);
            break;
        case DISCARD:
            break;
        default:
            throw new IllegalStateException("Unknown EventRoute " + eventRoute);
    }
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:24,代码来源:AsyncLogger.java

示例8: LogWriterLogger

import org.apache.logging.log4j.spi.AbstractLogger; //导入依赖的package包/类
private LogWriterLogger(final Logger logger, final String connectionName,
    final boolean isSecure) {
  super((AbstractLogger) logger, logger.getName(), logger.getMessageFactory());
  this.logWrapper = this;
  this.connectionName = connectionName;
  this.loggerName = getName();
  this.isSecure = isSecure;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:9,代码来源:LogWriterLogger.java

示例9: Log4j2Impl

import org.apache.logging.log4j.spi.AbstractLogger; //导入依赖的package包/类
public Log4j2Impl(Class<?> clazz) {
    Logger logger = LogManager.getLogger(clazz);

    if (logger instanceof AbstractLogger) {
        log = new Log4j2AbstractLoggerImpl((AbstractLogger) logger);
    } else {
        log = new Log4j2LoggerImpl(logger);
    }
}
 
开发者ID:nextyu,项目名称:summer-mybatis-generator,代码行数:10,代码来源:Log4j2Impl.java

示例10: Log4j2Impl

import org.apache.logging.log4j.spi.AbstractLogger; //导入依赖的package包/类
public Log4j2Impl(String clazz) {
    Logger logger = LogManager.getLogger(clazz);

    if (logger instanceof AbstractLogger) {
        log = new Log4j2AbstractLoggerImpl((AbstractLogger) logger);
    } else {
        log = new Log4j2LoggerImpl(logger);
    }
}
 
开发者ID:syhily,项目名称:elasticsearch-jdbc,代码行数:10,代码来源:Log4j2Impl.java

示例11: Log4j2Impl

import org.apache.logging.log4j.spi.AbstractLogger; //导入依赖的package包/类
public Log4j2Impl(String clazz) {
  Logger logger = LogManager.getLogger(clazz);

  if (logger instanceof AbstractLogger) {
    log = new Log4j2AbstractLoggerImpl((AbstractLogger) logger);
  } else {
    log = new Log4j2LoggerImpl(logger);
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:10,代码来源:Log4j2Impl.java

示例12: Log4j2Impl

import org.apache.logging.log4j.spi.AbstractLogger; //导入依赖的package包/类
public Log4j2Impl(String clazz) {
	Logger logger = LogManager.getLogger(clazz);

	if (logger instanceof AbstractLogger) {
		log = new Log4j2AbstractLoggerImpl((AbstractLogger) logger);
	} else {
		log = new Log4j2LoggerImpl(logger);
	}
}
 
开发者ID:Yoio,项目名称:YoioJava,代码行数:10,代码来源:Log4j2Impl.java

示例13: Log4j2Impl

import org.apache.logging.log4j.spi.AbstractLogger; //导入依赖的package包/类
public Log4j2Impl(String clazz) {
    Logger logger = LogManager.getLogger(clazz);

    if (logger instanceof AbstractLogger) {
        log = new Log4j2AbstractLoggerImpl((AbstractLogger)logger);
    } else {
        log = new Log4j2LoggerImpl(logger);
    }
}
 
开发者ID:aspectran,项目名称:aspectran,代码行数:10,代码来源:Log4j2Impl.java

示例14: getLogger

import org.apache.logging.log4j.spi.AbstractLogger; //导入依赖的package包/类
@Override
public Logger getLogger(final String name, final MessageFactory messageFactory) {
    if (loggers.containsKey(name)) {
        final Logger logger = loggers.get(name);
        AbstractLogger.checkMessageFactory(logger, messageFactory);
        return logger;
    }

    loggers.putIfAbsent(name, new SimpleLogger(name, defaultLevel, showLogName, showShortName, showDateTime,
            showContextMap, dateTimeFormat, messageFactory, props, stream));
    return loggers.get(name);
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:13,代码来源:SimpleLoggerContext.java

示例15: getInstance

import org.apache.logging.log4j.spi.AbstractLogger; //导入依赖的package包/类
@Override
public Log getInstance(final String name) throws LogConfigurationException {
    final ConcurrentMap<String, Log> loggers = getLoggersMap();
    if (loggers.containsKey(name)) {
        return loggers.get(name);
    }
    final org.apache.logging.log4j.Logger logger = PrivateManager.getLogger(name);
    if (logger instanceof AbstractLogger) {
        loggers.putIfAbsent(name, new Log4jLog((AbstractLogger) logger, name));
        return loggers.get(name);
    }
    throw new LogConfigurationException(
        "Commons Logging Adapter requires base logging system to extend Log4j AbstractLogger");
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:15,代码来源:LogFactoryImpl.java


注:本文中的org.apache.logging.log4j.spi.AbstractLogger类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。