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

Java ExtendedLogger类代码示例

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

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



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

示例1: PrefixLogger

import org.apache.logging.log4j.spi.ExtendedLogger; //导入依赖的package包/类
PrefixLogger(final ExtendedLogger logger, final String name, final String prefix) {
    super(logger, name, null);

    final String actualPrefix = (prefix == null ? "" : prefix).intern();
    final Marker actualMarker;
    // markers is not thread-safe, so we synchronize access
    synchronized (markers) {
        final WeakReference<Marker> marker = markers.get(actualPrefix);
        final Marker maybeMarker = marker == null ? null : marker.get();
        if (maybeMarker == null) {
            actualMarker = new MarkerManager.Log4jMarker(actualPrefix);
            markers.put(actualPrefix, new WeakReference<>(actualMarker));
        } else {
            actualMarker = maybeMarker;
        }
    }
    this.marker = actualMarker;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:PrefixLogger.java


示例2: getLogger

import org.apache.logging.log4j.spi.ExtendedLogger; //导入依赖的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: testLog4j2Only

import org.apache.logging.log4j.spi.ExtendedLogger; //导入依赖的package包/类
@Test
public void testLog4j2Only() throws InterruptedException {
    final org.apache.logging.log4j.Logger log4JLogger = LogManager.getLogger(this.getClass());
    final int limit = 11; // more than unrolled varargs
    final Object[] args = createArray(limit);
    final Object[] originalArgs = Arrays.copyOf(args, args.length);

    listAppender.countDownLatch = new CountDownLatch(1);
    ((ExtendedLogger)log4JLogger).logIfEnabled("test", Level.ERROR, null, "test {}", args);

    listAppender.countDownLatch.await(1, TimeUnit.SECONDS);
    Assert.assertArrayEquals(Arrays.toString(args), originalArgs, args);

    ((ExtendedLogger)log4JLogger).logIfEnabled("test", Level.ERROR, null, "test {}", args);
    Assert.assertArrayEquals(Arrays.toString(args), originalArgs, args);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:17,代码来源:Log4j2Jira1688AsyncTest.java


示例4: setUp

import org.apache.logging.log4j.spi.ExtendedLogger; //导入依赖的package包/类
@Before
public void setUp() {
  this.messageFactory = new ParameterizedMessageFactory();
  this.mockedLogger = mock(ExtendedLogger.class);
  this.mockedMarker = mock(Marker.class);

  when(this.mockedLogger.getMessageFactory()).thenReturn(this.messageFactory);
  when(this.mockedMarker.getName()).thenReturn("MARKER");
}
 
开发者ID:ampool,项目名称:monarch,代码行数:10,代码来源:FastLoggerJUnitTest.java


示例5: getLogger

import org.apache.logging.log4j.spi.ExtendedLogger; //导入依赖的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.ExtendedLogger; //导入依赖的package包/类
@Override
 public ExtendedLogger getLogger(final String name) {
     final ExtendedLogger extendedLogger = map.get(name);
     if (extendedLogger != null) {
return extendedLogger;
     }
     final ExtendedLogger logger = new TestLogger(name);
     map.put(name, logger);
     return logger;
 }
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:11,代码来源:TestLoggerContext.java


示例7: IoBuilder

import org.apache.logging.log4j.spi.ExtendedLogger; //导入依赖的package包/类
/**
 * Constructs a new IoBuilder for the given Logger. This method is provided for extensibility of this builder
 * class. The static factory methods should be used normally.
 *
 * @param logger the {@link ExtendedLogger} to wrap
 */
protected IoBuilder(final Logger logger) {
    if (!(logger instanceof ExtendedLogger)) {
        throw new UnsupportedOperationException("The provided Logger [" + String.valueOf(logger) +
            "] does not implement " + ExtendedLogger.class.getName());
    }
    this.logger = (ExtendedLogger) logger;
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:14,代码来源:IoBuilder.java


示例8: ByteStreamLogger

import org.apache.logging.log4j.spi.ExtendedLogger; //导入依赖的package包/类
public ByteStreamLogger(final ExtendedLogger logger, final Level level, final Marker marker, final Charset charset) {
    this.logger = logger;
    this.level = level == null ? logger.getLevel() : level;
    this.marker = marker;
    this.reader = new InputStreamReader(new ByteBufferInputStream(),
        charset == null ? Charset.defaultCharset() : charset);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:8,代码来源:ByteStreamLogger.java


示例9: ApiLogger

import org.apache.logging.log4j.spi.ExtendedLogger; //导入依赖的package包/类
ApiLogger(final ExtendedLogger logger) {
    super(logger.getName(), null);
    final Level javaLevel = LevelTranslator.toJavaLevel(logger.getLevel());
    // "java.util.logging.LoggingPermission" "control"
    AccessController.doPrivileged(new PrivilegedAction<Object>() {
        @Override
        public Object run() {
            ApiLogger.super.setLevel(javaLevel);
            return null;
        }
    });
    this.logger = new WrappedLogger(logger);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:14,代码来源:ApiLogger.java


示例10: getLogger

import org.apache.logging.log4j.spi.ExtendedLogger; //导入依赖的package包/类
@Override
public ExtendedLogger getLogger(final String name) {
    if (!loggerRegistry.hasLogger(name)) {
        loggerRegistry.putIfAbsent(name, null, new SLF4JLogger(name, LoggerFactory.getLogger(name)));
    }
    return loggerRegistry.getLogger(name);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:8,代码来源:SLF4JLoggerContext.java


示例11: getLogger

import org.apache.logging.log4j.spi.ExtendedLogger; //导入依赖的package包/类
public static Logger getLogger(String prefix, Logger logger) {
    return new PrefixLogger((ExtendedLogger)logger, logger.getName(), prefix);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:4,代码来源:ESLoggerFactory.java


示例12: FastLogger

import org.apache.logging.log4j.spi.ExtendedLogger; //导入依赖的package包/类
public FastLogger(final Logger logger) {
  this((ExtendedLogger) logger, logger.getName(), logger.getMessageFactory());
}
 
开发者ID:ampool,项目名称:monarch,代码行数:4,代码来源:FastLogger.java


示例13: getExtendedLogger

import org.apache.logging.log4j.spi.ExtendedLogger; //导入依赖的package包/类
public ExtendedLogger getExtendedLogger() {
  return super.logger;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:4,代码来源:FastLogger.java


示例14: Log4J2Logger

import org.apache.logging.log4j.spi.ExtendedLogger; //导入依赖的package包/类
Log4J2Logger(Logger logger) {
    super((ExtendedLogger) logger, logger.getName(), logger.getMessageFactory());
}
 
开发者ID:mayabot,项目名称:mynlp,代码行数:4,代码来源:Log4J2Logger.java


示例15: getLogger

import org.apache.logging.log4j.spi.ExtendedLogger; //导入依赖的package包/类
@Override
public ExtendedLogger getLogger(String name) {
    return getLogger(name, null);
}
 
开发者ID:neowu,项目名称:core-ng-project,代码行数:5,代码来源:ESLoggerContext.java


示例16: Log4j2Impl

import org.apache.logging.log4j.spi.ExtendedLogger; //导入依赖的package包/类
public Log4j2Impl(final Logger logger) {
    Assert.notNull(logger);
    this.logger = (ExtendedLogger) logger;
    setLoggerName(logger.getName());
}
 
开发者ID:nano-projects,项目名称:nano-framework,代码行数:6,代码来源:Log4j2Impl.java


示例17: createFileLogger

import org.apache.logging.log4j.spi.ExtendedLogger; //导入依赖的package包/类
/**
 * Creates a new file-logger for an addOn. The logger will log to a file with the addOnId as name in the logs folder
 * of Izou
 *
 * @param addOnId the Id of the addOn the logger is created for
 * @param level level of logger (at what level of log the logger should be activated
 * @return the new logger
 */
public synchronized ExtendedLogger createFileLogger(String addOnId, String level) {
    try {
        LoggerContext ctx = LogManager.getContext(false);
        Configuration config = ((org.apache.logging.log4j.core.LoggerContext) ctx).getConfiguration();

        //creates a new pattern layout (what determines how the log is formated, i.e. date, thread etc.)
        Layout layout = PatternLayout.createLayout("%d %-5p [%t] %C{10} (%F:%L) - %m%n", config, null, null, true,
                false, null, null);

        //creates a file appender for the logger (so that it knows what file to log to)
        Appender fileAppender = FileAppender.createAppender("logs" + File.separator + addOnId + ".log", "true",
                "false", "file", "true", "false", "false", "4000", layout, null, "false", null, config);
        fileAppender.start();
        config.addAppender(fileAppender);

        //creates also a console appender for the logger (so that the logger also outputs the log in the console)
        Appender consoleAppender = ConsoleAppender.createAppender(layout, null, "SYSTEM_OUT", "console", null, null);
        consoleAppender.start();
        config.addAppender(consoleAppender);

        //adds appenders to an array called refs. It will later serve as references to the logger as to what
        // appenders it has
        AppenderRef fileRef = AppenderRef.createAppenderRef("file", Level.DEBUG, null);
        AppenderRef consoleRef = AppenderRef.createAppenderRef("console", Level.DEBUG, null);
        AppenderRef[] refs = new AppenderRef[]{fileRef, consoleRef};

        //creates the logger configurations for the logger, where the appender-references are also added
        LoggerConfig loggerConfig = LoggerConfig.createLogger("false", Level.DEBUG, addOnId,
                "true", refs, null, config, null);
        loggerConfig.addAppender(fileAppender, Level.DEBUG, null);
        loggerConfig.addAppender(consoleAppender, Level.DEBUG, null);

        //finally creates the logger and returns it
        config.addLogger(addOnId, loggerConfig);
        ((org.apache.logging.log4j.core.LoggerContext) ctx).updateLoggers();
        ctx.getLogger(addOnId);
        ExtendedLogger logger = ctx.getLogger(addOnId);
        return logger;
    } catch(Exception e) {
        fileLogger.error("Unable to create FileLogger",e);
        return null;
    }
}
 
开发者ID:intellimate,项目名称:Izou,代码行数:52,代码来源:IzouLogger.java


示例18: ApimanLog4j2LogDelegate

import org.apache.logging.log4j.spi.ExtendedLogger; //导入依赖的package包/类
ApimanLog4j2LogDelegate(final String name) {
  logger = (ExtendedLogger) org.apache.logging.log4j.LogManager.getLogger(name, new FormattedMessageFactory());
}
 
开发者ID:apiman,项目名称:apiman,代码行数:4,代码来源:ApimanLog4j2LogDelegate.java


示例19: getLogger

import org.apache.logging.log4j.spi.ExtendedLogger; //导入依赖的package包/类
public static ExtendedLogger getLogger(final String name) {
    return getContext().getLogger(name);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:4,代码来源:TomcatLogger.java


示例20: Log4jTaglibLogger

import org.apache.logging.log4j.spi.ExtendedLogger; //导入依赖的package包/类
public Log4jTaglibLogger(final ExtendedLogger logger, final String name, final MessageFactory messageFactory) {
    super(logger, name, messageFactory);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:4,代码来源:Log4jTaglibLogger.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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