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


Java ConsoleAppender.setLayout方法代码示例

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


在下文中一共展示了ConsoleAppender.setLayout方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
@Before
public void init()
{
    LoggerContext ctx = (LoggerContext) LoggerFactory.getILoggerFactory();

    ctx.reset();

    this.layoutProducer = new LayoutProducer();
    ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<>();
    appender.setLayout(layoutProducer);
    appender.setContext(ctx);
    appender.start();

    Logger basicLogger = ctx.getLogger(LogFmtTest.class);
    basicLogger.addAppender(appender);
    this.logger = LogFmt.from(basicLogger);

    ctx.start();
}
 
开发者ID:BatchLabs,项目名称:escalog,代码行数:20,代码来源:LogFmtTest.java

示例2: doFailSafeConfiguration

import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
private void doFailSafeConfiguration() {
    // Not really fail-safe, just less likely to fail
    final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
    context.reset();
    Logger rootLogger = context.getLogger(Logger.ROOT_LOGGER_NAME);
    rootLogger.setLevel(Level.INFO);

    ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<ILoggingEvent>();
    rootLogger.addAppender(appender);
    appender.setContext(context);
    appender.setTarget("System.err");

    PatternLayout layout = new PatternLayout();
    appender.setLayout(layout);
    layout.setPattern("%msg%n%ex");
    layout.setContext(context);

    layout.start();
    appender.start();
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:21,代码来源:LogbackLoggingConfigurer.java

示例3: buildConsoleAppender

import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
public static ConsoleAppender<ILoggingEvent> buildConsoleAppender(LoggingConfiguration.ConsoleConfiguration console,
                                                                  LoggerContext context,
                                                                  String logFormat) {
    final LogFormatter formatter = new LogFormatter(context, console.getTimeZone());
    if (logFormat != null) {
        formatter.setPattern(logFormat);
    }
    formatter.start();

    final ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<ILoggingEvent>();
    appender.setContext(context);
    appender.setLayout(formatter);
    addThresholdFilter(appender, console.getThreshold());
    appender.start();

    return appender;
}
 
开发者ID:bither,项目名称:bither-desktop-java,代码行数:18,代码来源:LogbackFactory.java

示例4: getConsoleAppender

import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
private ConsoleAppender<ILoggingEvent> getConsoleAppender(final LoggingSettings.Console settings,
                                                                final LoggerContext context) {
    final PatternLayout formatter = getPatternLayout(context);
    formatter.setPattern(settings.getLogFormat());
    formatter.start();

    final ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<ILoggingEvent>();
    appender.setContext(context);
    appender.setLayout(formatter);

    addThresholdFilter(appender, settings.getThreshold());

    appender.start();

    return appender;
}
 
开发者ID:Metrink,项目名称:croquet,代码行数:17,代码来源:CroquetLoggingFactory.java

示例5: configureLogging

import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static void configureLogging(Level level) {
    ch.qos.logback.classic.Logger valverlog = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Version.class);
    valverlog.setLevel(ERROR);
    ch.qos.logback.classic.Logger reflog = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Reflections.class);
    reflog.setLevel(ERROR);
    ch.qos.logback.classic.Logger logger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger("ROOT");
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    ConsoleAppender console = (ConsoleAppender) logger.getAppender("console");
    logger.setLevel(level);
    console.stop();
    PatternLayout pl = new PatternLayout();
    pl.setPattern("%r %5p [%X{resource}] %m%n%nopex");
    pl.setContext(lc);
    pl.start();
    console.setLayout(pl);
    console.start();
}
 
开发者ID:Kloudtek,项目名称:kloudmake,代码行数:19,代码来源:Cli.java

示例6: buildConsoleAppender

import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
public static ConsoleAppender<ILoggingEvent> buildConsoleAppender(ConsoleLoggingConfiguration config,
                                                                  LoggerContext context) {
    final LogFormatter formatter = new LogFormatter(context, config.getTimeZone());
    for (String format : config.getLogFormat().asSet()) {
        formatter.setPattern(format);
    }
    formatter.start();

    final ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<ILoggingEvent>();
    appender.setContext(context);
    appender.setLayout(formatter);
    addThresholdFilter(appender, config.getThreshold());
    appender.start();

    return appender;

}
 
开发者ID:wotifgroup,项目名称:grails-lightweight-deploy,代码行数:18,代码来源:LogbackFactory.java

示例7: init

import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
/**
 * Programatically configures Logback initially.
 */
private static void init() {
	LoggerContext context = LOG.getLoggerContext();
	context.reset();
	
	PatternLayoutEncoder encoder = new PatternLayoutEncoder();
	encoder.setContext(context);
	encoder.setPattern("[%d{HH:mm:ss} %level] %msg%n");
	encoder.start();
	
	ConsoleAppender<ILoggingEvent> cAppender = new ConsoleAppender<ILoggingEvent>();
	cAppender.setName("STDOUT");
	cAppender.setContext(context);
	cAppender.setLayout(encoder.getLayout());
	cAppender.start();
	
	FileAppender<ILoggingEvent> fAppender = new FileAppender<ILoggingEvent>();
	fAppender.setName("FILE");
	fAppender.setFile("log.log");
	fAppender.setEncoder(encoder);
	fAppender.setContext(context);
	fAppender.start();
	
	LOG.addAppender(cAppender);
	LOG.addAppender(fAppender);
	LOG.setLevel(Boolean.parseBoolean(CONFIG.get("debug", "false")) ? Level.DEBUG : Level.INFO);
}
 
开发者ID:IAreKyleW00t,项目名称:aradiabot,代码行数:30,代码来源:Main.java

示例8: getConsoleAppender

import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
public static ConsoleAppender<ILoggingEvent> getConsoleAppender(PatternLayout layout, Context context) {
  ConsoleAppender<ILoggingEvent> consoleAppender = new ConsoleAppender<ILoggingEvent>();
  consoleAppender.setContext(context);
  consoleAppender.setLayout(layout);
  consoleAppender.start();
  return consoleAppender;
}
 
开发者ID:apache,项目名称:lens,代码行数:8,代码来源:LensConnectionCommands.java

示例9: setupConsoleLogging

import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
private static void setupConsoleLogging(Logger root, ThresholdFilter filter) {
    MinimalLayout formatter = new MinimalLayout(root.getLoggerContext());
    formatter.start();

    ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<>();
    appender.addFilter(filter);
    appender.setContext(root.getLoggerContext());
    appender.setLayout(formatter);
    appender.start();

    root.addAppender(appender);
}
 
开发者ID:redbooth,项目名称:baseline,代码行数:13,代码来源:Logging.java

示例10: init

import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
private void init() {
	LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
	PatternLayoutEncoder ple = new PatternLayoutEncoder();
	
	ple.setPattern("[%d{HH:mm:ss} %level] [" + NAME + "] %msg%n");
	ple.setContext(lc);
	ple.start();
	
	ConsoleAppender<ILoggingEvent> ca = new ConsoleAppender<ILoggingEvent>();
	ca.setName("STDOUT");
	ca.setContext(lc);
	ca.setLayout(ple.getLayout());
	ca.start();
	
	FileAppender<ILoggingEvent> fa = new FileAppender<ILoggingEvent>();
	fa.setName("FILE");
	fa.setFile("log.log");
	fa.setEncoder(ple);
	fa.setContext(lc);
	fa.start();
	
	LOG = (Logger) LoggerFactory.getLogger(NAME);
	LOG.addAppender(ca);
	LOG.addAppender(fa);
	if (Aradiabot.isDebugging()) {
		LOG.setLevel(Level.DEBUG);
	} else {
		LOG.setLevel(Level.INFO);
	}
	LOG.setAdditive(false);
	
	try {
		LOG.info("Enabling " + NAME + " v" + VER);
		if (this.onEnable()) {
			this.setEnabled(true);
			return;
		} else {
			throw new Exception("Error occured when enabling plugin");
		}
	} catch (Exception e) {
		e.printStackTrace();
		LOG.error("Disabling "+ NAME + " v" + VER);
		this.setEnabled(false);
		try {
			this.onDisable();
			return;
		} catch (Exception e1) {
			e1.printStackTrace();
			LOG.error("Error disabling plugin: " + e1.getMessage());
		}
	}
}
 
开发者ID:IAreKyleW00t,项目名称:aradiabot,代码行数:53,代码来源:IRCPlugin.java


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