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


Java ConsoleAppender.setName方法代码示例

本文整理汇总了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);
}
 
开发者ID:trajano,项目名称:app-ms,代码行数:19,代码来源:LogConfigurator.java

示例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;
}
 
开发者ID:secondbase,项目名称:secondbase,代码行数:24,代码来源:SecondBaseLogger.java

示例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);
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:25,代码来源:LoggingConfigurator.java

示例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);
}
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:19,代码来源:KonkerLoggerBasicConfigurator.java

示例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);
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:19,代码来源:BasicConfigurator.java

示例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);
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:21,代码来源:JettyFixtureWithListAndConsoleAppenders.java

示例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);
}
 
开发者ID:strator-dev,项目名称:greenpepper,代码行数:22,代码来源:DefaultLogbackConfigurator.java

示例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);
}
 
开发者ID:strator-dev,项目名称:greenpepper,代码行数:23,代码来源:DefaultLogbackConfigurator.java

示例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);
  }
}
 
开发者ID:irenical,项目名称:jindy,代码行数:26,代码来源:LoggerConfigurator.java

示例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);
}
 
开发者ID:wmluke,项目名称:pipes,代码行数:27,代码来源:LogbackConfig.java

示例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);
    }
 
开发者ID:Schnitker,项目名称:LogManager,代码行数:23,代码来源:LogConfigurator.java

示例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;
}
 
开发者ID:spotify,项目名称:logging-java,代码行数:27,代码来源:LoggingConfigurator.java

示例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);
}
 
开发者ID:NimbleGen,项目名称:bioinformatics,代码行数:19,代码来源:LoggingUtil.java

示例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")));
}
 
开发者ID:gzlabs,项目名称:hightide,代码行数:17,代码来源:LoggingInitializer.java

示例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();
}
 
开发者ID:vrajat,项目名称:nomadacris,代码行数:15,代码来源:Nomadacris.java


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