本文整理汇总了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();
}
示例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();
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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());
}
}
}