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


Java ConsoleAppender.start方法代码示例

本文整理汇总了Java中ch.qos.logback.core.ConsoleAppender.start方法的典型用法代码示例。如果您正苦于以下问题:Java ConsoleAppender.start方法的具体用法?Java ConsoleAppender.start怎么用?Java ConsoleAppender.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ch.qos.logback.core.ConsoleAppender的用法示例。


在下文中一共展示了ConsoleAppender.start方法的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: 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();
}
 
开发者ID:BatchLabs,项目名称:escalog,代码行数:20,代码来源:LogFmtTest.java

示例3: 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

示例4: 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

示例5: log

import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
@Test
public void log() throws Exception {
    Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    LoggerContext context = logger.getLoggerContext();
    context.reset();

    Map<String, String> ruleRegistry = (Map) context.getObject(CoreConstants.PATTERN_RULE_REGISTRY);
    if (ruleRegistry == null) {
        ruleRegistry = new HashMap<String, String>();
        context.putObject(CoreConstants.PATTERN_RULE_REGISTRY, ruleRegistry);
    }
    ruleRegistry.put("ex1L", OnelineThrowableProxyConverter.class.getCanonicalName());

    PatternLayoutEncoder encoder = new PatternLayoutEncoder();
    encoder.setContext(context);
    encoder.setPattern("%d{yyyy/MM/dd HH:mm:ss:SSS}\\t%-5level\\t%msg\\t%ex1L");
    encoder.start();

    ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<ILoggingEvent>();
    appender.setContext(context);
    appender.setEncoder(encoder);
    appender.start();
    logger.addAppender(appender);

    logger.error("error", new RuntimeException("foo"));
}
 
开发者ID:roundrop,项目名称:logback-oneline-converter,代码行数:27,代码来源:OnelineThrowableProxyConverterTest.java

示例6: log

import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
@Test
public void log() throws Exception {
    Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    LoggerContext context = logger.getLoggerContext();
    context.reset();

    Map<String, String> ruleRegistry = (Map) context.getObject(CoreConstants.PATTERN_RULE_REGISTRY);
    if (ruleRegistry == null) {
        ruleRegistry = new HashMap<String, String>();
        context.putObject(CoreConstants.PATTERN_RULE_REGISTRY, ruleRegistry);
    }
    ruleRegistry.put("xEx1L", OnelineExtendedThrowableProxyConverter.class.getCanonicalName());

    PatternLayoutEncoder encoder = new PatternLayoutEncoder();
    encoder.setContext(context);
    encoder.setPattern("%d{yyyy/MM/dd HH:mm:ss:SSS}\\t%-5level\\t%msg\\t%xEx1L");
    encoder.start();

    ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<ILoggingEvent>();
    appender.setContext(context);
    appender.setEncoder(encoder);
    appender.start();
    logger.addAppender(appender);

    logger.error("error", new RuntimeException());
}
 
开发者ID:roundrop,项目名称:logback-oneline-converter,代码行数:27,代码来源:OnelineExtendedThrowableProxyConverterTest.java

示例7: 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

示例8: build

import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
public Appender<ILoggingEvent> build(
    LoggerContext context,
    String applicationName,
    LayoutFactory<ILoggingEvent> layoutFactory,
    LevelFilterFactory<ILoggingEvent> levelFilterFactory,
    AsyncAppenderFactory<ILoggingEvent> asyncAppenderFactory
  ) {

  final LoggingEventCompositeJsonEncoder encoder = new LoggingEventCompositeJsonEncoder();
  encoder.setContext(context);

  encoder.getProviders().addProvider(withPattern("{ \"type\": \"system\" }", new LoggingEventPatternJsonProvider(), context));
  encoder.getProviders().addProvider(withName("timestamp", new LoggingEventFormattedTimestampJsonProvider(), context));
  encoder.getProviders().addProvider(new LogLevelJsonProvider() );
  encoder.getProviders().addProvider(new MessageJsonProvider() );
  encoder.getProviders().addProvider(new StackTraceJsonProvider() );

  encoder.start();

  final ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<>();
  appender.setContext(context);
  appender.setEncoder(encoder);
  appender.start();

  return wrapAsync(appender, asyncAppenderFactory);
}
 
开发者ID:atgse,项目名称:sam,代码行数:27,代码来源:JsonLogAppender.java

示例9: wrongTarget

import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
@Test
  public void wrongTarget() {
    ConsoleAppender<Object> ca = (ConsoleAppender<Object>) getAppender();
    EchoEncoder<Object> encoder = new EchoEncoder<Object>();
    encoder.setContext(context);
    ca.setContext(context);
    ca.setTarget("foo");
    ca.setEncoder(encoder);
    ca.start();
    ca.doAppend("a");
    StatusChecker checker = new StatusChecker(context);
    //21:28:01,246 + WARN in ch.qos.logback.core.ConsoleAppender[null] - [foo] should be one of [SystemOut, SystemErr]
    //21:28:01,246   |-WARN in ch.qos.logback.core.ConsoleAppender[null] - Using previously set target, System.out by default.
//    StatusPrinter.print(context);

    checker.assertContainsMatch(Status.WARN, "\\[foo\\] should be one of \\[SystemOut, SystemErr\\]");

  }
 
开发者ID:cscfa,项目名称:bartleby,代码行数:19,代码来源:ConsoleAppenderTest.java

示例10: 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

示例11: main

import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
static public void main(String[] args) throws Exception {
  Logger rootLogger = (Logger) LoggerFactory.getLogger("root");
  LoggerContext loggerContext = rootLogger.getLoggerContext();
  loggerContext.reset();
  
  PatternLayoutEncoder encoder = new PatternLayoutEncoder();
  encoder.setContext(loggerContext);
  encoder.setPattern("%-5level [%thread]: %message%n");
  encoder.start();
  
  ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<ILoggingEvent>();
  appender.setContext(loggerContext);
  appender.setEncoder(encoder);
  appender.start();
  
  rootLogger.addAppender(appender);

  rootLogger.debug("Message 1");
  rootLogger.warn("Message 2");
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:21,代码来源:PatternSample.java

示例12: programmaticConfiguration

import ch.qos.logback.core.ConsoleAppender; //导入方法依赖的package包/类
static void programmaticConfiguration() {
  // Configure logback
  LoggerContext loggerContext = (LoggerContext) LoggerFactory
      .getILoggerFactory();
  loggerContext.reset();
  PatternLayoutEncoder layout = new PatternLayoutEncoder();
  layout.setContext(loggerContext);
  layout.setPattern("%X{first} %X{last} - %m%n");
  layout.start();
  ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<ILoggingEvent>();
  appender.setContext(loggerContext);
  appender.setEncoder(layout);
  appender.start();
  // cast root logger to c.q.logback.classic.Logger so that we can attach
  // an appender to it
  ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory
      .getLogger("root");
  root.addAppender(appender);
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:20,代码来源:SimpleMDC.java

示例13: 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

示例14: 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

示例15: 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


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