本文整理汇总了Java中ch.qos.logback.core.ConsoleAppender.setName方法的典型用法代码示例。如果您正苦于以下问题:Java ConsoleAppender.setName方法的具体用法?Java ConsoleAppender.setName怎么用?Java ConsoleAppender.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ch.qos.logback.core.ConsoleAppender
的用法示例。
在下文中一共展示了ConsoleAppender.setName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configure
import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
@Override
public void configure(final LoggerContext lc) {
final ConsoleAppender<ILoggingEvent> ca = new ConsoleAppender<>();
ca.setContext(lc);
ca.setName("console");
final LayoutWrappingEncoder<ILoggingEvent> encoder = new LayoutWrappingEncoder<>();
encoder.setContext(lc);
final TTLLLayout layout = new TTLLLayout();
layout.setContext(lc);
layout.start();
encoder.setLayout(layout);
ca.setEncoder(encoder);
ca.start();
final Logger rootLogger = lc.getLogger("ROOT");
rootLogger.setLevel(Level.WARN);
rootLogger.addAppender(ca);
}
示例2: createJsonConsoleAppender
import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
/**
* Set up a {@link ConsoleAppender} using a {@link LoggingEventCompositeJsonEncoder} to log to
* stdout. Package-private for testing.
* @param loggerContext to use for setup
* @param appenderName name of the appender
* @param serviceLog return appender for service logs if true, else return one for request logs
* @return console appender
*/
static ConsoleAppender<ILoggingEvent> createJsonConsoleAppender(
final String appenderName,
final LoggerContext loggerContext,
final boolean serviceLog) {
final LoggingEventCompositeJsonEncoder jsonEncoder = getEncoder(loggerContext, serviceLog);
final ConsoleAppender<ILoggingEvent> consoleAppender = new ConsoleAppender<>();
consoleAppender.setContext(loggerContext);
consoleAppender.setName(appenderName);
consoleAppender.setEncoder(jsonEncoder);
consoleAppender.start();
return consoleAppender;
}
示例3: configure
import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
@Override
public void configure(LoggerContext lc) {
addInfo("Setting up robot logging configuration.");
ConsoleAppender<ILoggingEvent> ca = new ConsoleAppender<>();
ca.setContext(lc);
ca.setName("console");
LayoutWrappingEncoder<ILoggingEvent> encoder = new LayoutWrappingEncoder<>();
encoder.setContext(lc);
PatternLayout layout = new PatternLayout();
layout.setPattern("%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n");
layout.setContext(lc);
layout.start();
encoder.setLayout(layout);
ca.setEncoder(encoder);
ca.start();
Logger rootLogger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
rootLogger.addAppender(ca);
rootLogger.setLevel(Level.DEBUG);
}
示例4: configure
import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
public static void configure(KonkerLoggerContext lc) {
StatusManager sm = lc.getStatusManager();
if(sm != null) {
sm.add(new InfoStatus("Setting up default configuration.", lc));
}
ConsoleAppender ca = new ConsoleAppender();
ca.setContext(lc);
ca.setName("console");
PatternLayoutEncoder pl = new PatternLayoutEncoder();
pl.setContext(lc);
pl.setPattern("%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n");
pl.start();
ca.setEncoder(pl);
ca.start();
KonkerLogger rootLogger = lc.getLogger("ROOT");
rootLogger.addAppender(ca);
}
示例5: configure
import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
public static void configure(LoggerContext lc) {
StatusManager sm = lc.getStatusManager();
if(sm != null) {
sm.add(new InfoStatus("Setting up default configuration.", lc));
}
ConsoleAppender<ILoggingEvent> ca = new ConsoleAppender<ILoggingEvent>();
ca.setContext(lc);
ca.setName("console");
PatternLayoutEncoder pl = new PatternLayoutEncoder();
pl.setContext(lc);
pl.setPattern("%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n");
pl.start();
ca.setEncoder(pl);
ca.start();
Logger rootLogger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
rootLogger.addAppender(ca);
}
示例6: configureRequestLogImpl
import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
@Override
protected void configureRequestLogImpl() {
NotifyingListAppender appender = new NotifyingListAppender();
appender.setContext(requestLogImpl);
appender.setName("list");
appender.start();
ConsoleAppender<IAccessEvent> console = new ConsoleAppender<IAccessEvent>();
console.setContext(requestLogImpl);
console.setName("console");
PatternLayoutEncoder layout = new PatternLayoutEncoder();
layout.setContext(requestLogImpl);
layout.setPattern("%date %server %clientHost");
console.setEncoder(layout);
layout.start();
console.start();
requestLogImpl.addAppender(appender);
requestLogImpl.addAppender(console);
}
示例7: configure
import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public void configure(LoggerContext loggerContext) {
StatusManager sm = loggerContext.getStatusManager();
if (sm != null) {
sm.add(new InfoStatus("Setting up GreenPepper PHP Runner configuration.", loggerContext));
}
ConsoleAppender<ILoggingEvent> ca = new ConsoleAppender<ILoggingEvent>();
ca.setContext(loggerContext);
ca.setName("console");
PatternLayoutEncoder pl = new PatternLayoutEncoder();
pl.setContext(loggerContext);
pl.setPattern("%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %-36logger{36} - %msg%n");
pl.start();
ca.setEncoder(pl);
ca.start();
Logger rootLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
rootLogger.addAppender(ca);
rootLogger.setLevel(Level.INFO);
}
示例8: configure
import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public void configure(LoggerContext loggerContext) {
StatusManager sm = loggerContext.getStatusManager();
if (sm != null) {
sm.add(new InfoStatus("Setting up default configuration.", loggerContext));
}
ConsoleAppender<ILoggingEvent> ca = new ConsoleAppender<ILoggingEvent>();
ca.setContext(loggerContext);
ca.setName("console");
PatternLayoutEncoder pl = new PatternLayoutEncoder();
pl.setContext(loggerContext);
pl.setPattern("[%-5level] %msg%n");
pl.start();
ca.setEncoder(pl);
ca.start();
Logger rootLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
rootLogger.addAppender(ca);
rootLogger.setLevel(Level.WARN);
loggerContext.getLogger("com.greenpepper.maven.plugin").setLevel(Level.INFO);
}
示例9: updateConsole
import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
private void updateConsole(String changedProp) {
LoggerContext loggerContext = (LoggerContext) getContext();
Logger logbackLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
ConsoleAppender<ILoggingEvent> consoleAppender = (ConsoleAppender<ILoggingEvent>) logbackLogger
.getAppender(APPENDER_CONSOLE);
if (config.getBoolean(CONSOLE_ENABLED, true)) {
logbackLogger.detachAppender(consoleAppender);
consoleAppender = new ConsoleAppender<>();
consoleAppender.setContext(loggerContext);
consoleAppender.setName(APPENDER_CONSOLE);
PatternLayoutEncoder encoder = new PatternLayoutEncoder();
encoder.setContext(loggerContext);
encoder.setPattern(config.getString(CONSOLE_PATTERN, DEFAULT_PATTERN));
consoleAppender.setEncoder(encoder);
encoder.start();
consoleAppender.start();
logbackLogger.addAppender(consoleAppender);
} else {
logbackLogger.detachAppender(consoleAppender);
}
}
示例10: configure
import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
public static void configure(LoggerContext loggerContext) {
loggerContext.reset();
StatusManager sm = loggerContext.getStatusManager();
if (sm != null) {
sm.add(new InfoStatus("Setting up default Pipes configuration.", loggerContext));
}
ConsoleAppender<ILoggingEvent> ca = new ConsoleAppender<>();
ca.setContext(loggerContext);
ca.setWithJansi(true);
ca.setName("console");
PatternLayoutEncoder pl = new PatternLayoutEncoder();
pl.setCharset(Charset.forName("UTF-8"));
pl.setContext(loggerContext);
//pl.setPattern("%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n");
pl.setPattern("%msg%n");
pl.start();
ca.setEncoder(pl);
ca.start();
ch.qos.logback.classic.Logger rootLogger = loggerContext.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
rootLogger.setLevel(Level.INFO);
rootLogger.addAppender(ca);
}
示例11: configure
import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
public static LogConfigurator configure() {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
lc.reset();
ConsoleAppender<ILoggingEvent> ca = new ConsoleAppender<ILoggingEvent>();
ca.setContext(lc);
ca.setName("console");
PatternLayoutEncoder pl = new PatternLayoutEncoder();
pl.setContext(lc);
pl.setPattern("%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n");
pl.start();
ca.setEncoder(pl);
ca.start();
Logger rootLogger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
rootLogger.addAppender(ca);
return new LogConfigurator(ca);
}
示例12: getStdErrAppender
import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
/**
* Create a stderr appender.
*
* @param context The logger context to use.
* @return An appender writing to stderr.
*/
private static Appender<ILoggingEvent> getStdErrAppender(final LoggerContext context) {
// Setup format
final PatternLayoutEncoder encoder = new PatternLayoutEncoder();
encoder.setContext(context);
encoder.setPattern(
"%date{HH:mm:ss.SSS} %property{ident}[%property{pid}]: %-5level [%thread] %logger{0}: %msg%n");
encoder.setCharset(Charsets.UTF_8);
encoder.start();
// Setup stderr appender
final ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<ILoggingEvent>();
appender.setTarget("System.err");
appender.setName("stderr");
appender.setEncoder(encoder);
appender.setContext(context);
appender.start();
return appender;
}
示例13: outputLogsToConsole
import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
public static void outputLogsToConsole(String loggerName, String sessionId) {
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
PatternLayoutEncoder encoder = new PatternLayoutEncoder();
encoder.setContext(loggerContext);
encoder.setPattern("SESSION:" + sessionId + ENCODER_PATTERN);
encoder.setImmediateFlush(true);
encoder.start();
ConsoleAppender<ILoggingEvent> logConsoleAppender = new ConsoleAppender<ILoggingEvent>();
logConsoleAppender.setContext(loggerContext);
logConsoleAppender.setName("console");
logConsoleAppender.setEncoder(encoder);
logConsoleAppender.start();
Logger log = loggerContext.getLogger(loggerName);
log.addAppender(logConsoleAppender);
}
示例14: init
import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
public static void init() {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<>();
appender.setContext(context);
appender.setName("console-logger");
PatternLayoutEncoder encoder = new PatternLayoutEncoder();
encoder.setContext(context);
encoder.setPattern(config.getString("log.pattern"));
encoder.start();
Logger rootLogger = context.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
rootLogger.addAppender(appender);
rootLogger.setLevel(toLevel(config.getString("log.level")));
}
示例15: setupLogger
import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
private static void setupLogger() {
LoggerContext logCtx = (LoggerContext) LoggerFactory.getILoggerFactory();
PatternLayoutEncoder logEncoder = new PatternLayoutEncoder();
logEncoder.setContext(logCtx);
logEncoder.setPattern("%-12date{YYYY-MM-dd HH:mm:ss.SSS} %-5level - %msg%n");
logEncoder.start();
ConsoleAppender logConsoleAppender = new ConsoleAppender();
logConsoleAppender.setContext(logCtx);
logConsoleAppender.setName("console");
logConsoleAppender.setEncoder(logEncoder);
logConsoleAppender.start();
}