本文整理匯總了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());
}
}
}