• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AbstractLogger类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: getLogger

import org.apache.logging.log4j.spi.AbstractLogger; //导入依赖的package包/类
/**
 * Obtain a Logger from the Context.
 * @param name The name of the Logger to return.
 * @param messageFactory The message factory is used only when creating a
 *            logger, subsequent use does not change the logger but will log
 *            a warning if mismatched.
 * @return The Logger.
 */
@Override
public Logger getLogger(final String name, final MessageFactory messageFactory) {
    Logger logger = loggers.get(name);
    if (logger != null) {
        AbstractLogger.checkMessageFactory(logger, messageFactory);
        return logger;
    }

    logger = newInstance(this, name, messageFactory);
    final Logger prev = loggers.putIfAbsent(name, logger);
    return prev == null ? logger : prev;
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:21,代码来源:LoggerContext.java


示例17: getLogger

import org.apache.logging.log4j.spi.AbstractLogger; //导入依赖的package包/类
@Override
public ExtendedLogger getLogger(final String name, final MessageFactory messageFactory) {
    // Note: This is the only method where we add entries to the 'loggerRegistry' ivar.
    final ExtendedLogger extendedLogger = loggerRegistry.getLogger(name, messageFactory);
    if (extendedLogger != null) {
        AbstractLogger.checkMessageFactory(extendedLogger, messageFactory);
        return extendedLogger;
    }
    final SimpleLogger simpleLogger = new SimpleLogger(name, defaultLevel, showLogName, showShortName, showDateTime,
            showContextMap, dateTimeFormat, messageFactory, props, stream);
    loggerRegistry.putIfAbsent(name, messageFactory, simpleLogger);
    return loggerRegistry.getLogger(name, messageFactory);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:14,代码来源:SimpleLoggerContext.java


示例18: checkMessageFactory

import org.apache.logging.log4j.spi.AbstractLogger; //导入依赖的package包/类
private static void checkMessageFactory(final String msg, final MessageFactory messageFactory1,
        final Logger testLogger1) {
    if (messageFactory1 == null) {
        assertEquals(msg, AbstractLogger.DEFAULT_MESSAGE_FACTORY_CLASS,
                testLogger1.getMessageFactory().getClass());
    } else {
        MessageFactory actual = testLogger1.getMessageFactory();
        if (actual instanceof MessageFactory2Adapter) {
            actual = ((MessageFactory2Adapter) actual).getOriginal();
        }
        assertEquals(msg, messageFactory1, actual);
    }
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:14,代码来源:SetLoggerTagTest.java


示例19: checkMessageFactory

import org.apache.logging.log4j.spi.AbstractLogger; //导入依赖的package包/类
private static void checkMessageFactory(final MessageFactory messageFactory1, final Logger testLogger1) {
    if (messageFactory1 == null) {
        assertEquals(AbstractLogger.DEFAULT_MESSAGE_FACTORY_CLASS, testLogger1.getMessageFactory().getClass());
    } else {
        MessageFactory actual = testLogger1.getMessageFactory();
        if (actual instanceof MessageFactory2Adapter) {
            actual = ((MessageFactory2Adapter) actual).getOriginal();
        }
        assertEquals(messageFactory1, actual);
    }
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:12,代码来源:LoggerTest.java


示例20: getLogger

import org.apache.logging.log4j.spi.AbstractLogger; //导入依赖的package包/类
/**
 * Obtains a Logger from the Context.
 *
 * @param name The name of the Logger to return.
 * @param messageFactory The message factory is used only when creating a logger, subsequent use does not change the
 *            logger but will log a warning if mismatched.
 * @return The Logger.
 */
@Override
public Logger getLogger(final String name, final MessageFactory messageFactory) {
    // Note: This is the only method where we add entries to the 'loggerRegistry' ivar.
    Logger logger = loggerRegistry.getLogger(name, messageFactory);
    if (logger != null) {
        AbstractLogger.checkMessageFactory(logger, messageFactory);
        return logger;
    }

    logger = newInstance(this, name, messageFactory);
    loggerRegistry.putIfAbsent(name, messageFactory, logger);
    return loggerRegistry.getLogger(name, messageFactory);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:22,代码来源:LoggerContext.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NetworkTopology类代码示例发布时间:2022-05-21
下一篇:
Java RestApiServer类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap