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


Java AbstractLogger.checkMessageFactory方法代码示例

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


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

示例3: 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

示例4: 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

示例5: 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

示例6: 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.checkMessageFactory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。