當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。