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