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


Java PatternLayout.start方法代码示例

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


在下文中一共展示了PatternLayout.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configure

import ch.qos.logback.classic.PatternLayout; //导入方法依赖的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

示例2: enablePaperTrail

import ch.qos.logback.classic.PatternLayout; //导入方法依赖的package包/类
private static void enablePaperTrail(final String hostname, final int port, final String ident) {
    final LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();

    final PatternLayout patternLayout = new PatternLayout();
    patternLayout.setContext(lc);
    patternLayout.setPattern(LOG_PATTERN);
    patternLayout.start();

    final SSLTCPNetSyslogConfig syslogConfig = new SSLTCPNetSyslogConfig(hostname, port);
    syslogConfig.setIdent(ident);
    syslogConfig.setMaxMessageLength(128000);
    syslogConfig.setSendLocalTimestamp(false);
    syslogConfig.setSendLocalName(false);

    final Syslog4jAppender<ILoggingEvent> syslog4jAppender = new Syslog4jAppender<>();
    syslog4jAppender.setSyslogConfig(syslogConfig);
    syslog4jAppender.setLayout(patternLayout);
    syslog4jAppender.start();

    final Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);

    logger.addAppender(syslog4jAppender);
    logger.setLevel(Level.DEBUG);
    logger.setAdditive(true); /* set to true if root should log too */
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:26,代码来源:PapertrailConfig.java

示例3: callerData

import ch.qos.logback.classic.PatternLayout; //导入方法依赖的package包/类
@Test
public void callerData() {
  assertEquals(0, listAppender.list.size());

  PatternLayout pl = new PatternLayout();
  pl.setPattern("%-5level [%class] %logger - %msg");
  pl.setContext(lc);
  pl.start();
  listAppender.layout = pl;

  Logger logger = Logger.getLogger("basic-test");
  logger.trace("none");
  assertEquals(0, listAppender.list.size());
  
  rootLogger.setLevel(Level.TRACE);
  logger.trace(HELLO);
  assertEquals(1, listAppender.list.size());

  ILoggingEvent event = (ILoggingEvent) listAppender.list.get(0);
  assertEquals(HELLO, event.getMessage());

  assertEquals(1, listAppender.stringList.size());
  assertEquals("TRACE [" + Log4jInvocation.class.getName()
      + "] basic-test - Hello", listAppender.stringList.get(0));
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:26,代码来源:Log4jInvocation.java

示例4: integration

import ch.qos.logback.classic.PatternLayout; //导入方法依赖的package包/类
@Test
public void integration() {
  PatternLayout pl = new PatternLayout();
  pl.setContext(lc);
  pl.setPattern("%m%n");
  pl.start();
  ILoggingEvent e = createLoggingEvent(new Exception("x"));
  String res = pl.doLayout(e);

  // make sure that at least some package data was output
  Pattern p = Pattern.compile("\\s*at .*?\\[.*?\\]");
  Matcher m = p.matcher(res);
  int i = 0;
  while(m.find()) {
    i++;
  }
  assertTrue(i+ " should be larger than 5", i > 5);
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:19,代码来源:ExtendedThrowableProxyConverterTest.java

示例5: integration

import ch.qos.logback.classic.PatternLayout; //导入方法依赖的package包/类
@Test
public void integration() {
  //given
  PatternLayout pl = new PatternLayout();
  pl.setContext(context);
  pl.setPattern("%m%rEx%n");
  pl.start();

  //when
  ILoggingEvent e = createLoggingEvent(new Exception("x"));
  String result = pl.doLayout(e);

  //then
  // make sure that at least some package data was output
  Pattern p = Pattern.compile("\\s*at .*?\\[.*?\\]");
  Matcher m = p.matcher(result);
  int i = 0;
  while(m.find()) {
    i++;
  }
  assertThat(i).isGreaterThan(5);
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:23,代码来源:RootCauseFirstThrowableProxyConverterTest.java

示例6: doFailSafeConfiguration

import ch.qos.logback.classic.PatternLayout; //导入方法依赖的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();
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:21,代码来源:LogbackLoggingConfigurer.java

示例7: start

import ch.qos.logback.classic.PatternLayout; //导入方法依赖的package包/类
@Override
public void start()
{
    if (isStarted()) {
        return;
    }

    PatternLayout patternLayout = new PatternLayout();
    patternLayout.setContext(context);
    patternLayout.setPattern(PATTERN);
    patternLayout.setOutputPatternAsHeader(false);
    patternLayout.start();
    this.layout = patternLayout;

    super.start();
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:17,代码来源:LogbackTaskContextLoggerBridgeAppender.java

示例8: buildAppender

import ch.qos.logback.classic.PatternLayout; //导入方法依赖的package包/类
protected Appender buildAppender(String name, String fileName, String pattern) {
    RollingFileAppender appender = new RollingFileAppender();
    appender.setContext(loggerContext);
    appender.setName(name);
    appender.setAppend(true);
    appender.setFile(new File(getLogPath(), fileName).getAbsolutePath());

    TimeBasedRollingPolicy rolling = new TimeBasedRollingPolicy();
    rolling.setParent(appender);
    rolling.setFileNamePattern(new File(getLogPath(), fileName).getAbsolutePath() + ".%d{yyyy-MM-dd}");
    rolling.setContext(loggerContext);
    rolling.start();
    appender.setRollingPolicy(rolling);

    PatternLayout layout = new PatternLayout();
    layout.setPattern(pattern);
    layout.setContext(loggerContext);
    layout.start();
    appender.setLayout(layout);
    // 启动
    appender.start();
    return appender;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:24,代码来源:DynamicLogback918Logger.java

示例9: buildDailyMaxRollingAppender

import ch.qos.logback.classic.PatternLayout; //导入方法依赖的package包/类
protected Appender buildDailyMaxRollingAppender(String name, String fileName, String pattern, int maxBackupIndex) {
    RollingFileAppender appender = new RollingFileAppender();
    appender.setContext(loggerContext);
    appender.setName(name);
    appender.setAppend(true);
    appender.setFile(new File(getLogPath(), fileName).getAbsolutePath());

    TimeBasedRollingPolicy rolling = new TimeBasedRollingPolicy();
    rolling.setContext(loggerContext);
    rolling.setFileNamePattern(new File(getLogPath(), fileName).getAbsolutePath() + ".%d{yyyy-MM-dd-HH}");
    rolling.setMaxHistory(maxBackupIndex);
    rolling.setParent(appender);
    rolling.start();
    appender.setRollingPolicy(rolling);

    PatternLayout layout = new PatternLayout();
    layout.setContext(loggerContext);
    layout.setPattern(pattern);
    layout.start();
    appender.setLayout(layout);
    // 启动
    appender.start();
    return appender;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:25,代码来源:DynamicLogback918Logger.java

示例10: getConsoleAppender

import ch.qos.logback.classic.PatternLayout; //导入方法依赖的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;
}
 
开发者ID:Metrink,项目名称:croquet,代码行数:17,代码来源:CroquetLoggingFactory.java

示例11: setUp

import ch.qos.logback.classic.PatternLayout; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    _context = new LoggerContext();
    _context.start();
    _baos = new ByteArrayOutputStream();
    _encoder = new KeyValueEncoder();
    _encoder.setImmediateFlush(true);

    final PatternLayout layout = new PatternLayout();
    layout.setPattern("[%d{dd MMM yyyy HH:mm:ss.SSS,UTC}] %t - %m%n");
    layout.setContext(_context);
    layout.start();
    _encoder.setLayout(layout);
    _encoder.setContext(_context);
    Mockito.doThrow(new RuntimeException("Mocked Failure")).when(_throwingLayout).doLayout(Mockito.any(ILoggingEvent.class));
}
 
开发者ID:ArpNetworking,项目名称:logback-steno,代码行数:18,代码来源:KeyValueEncoderTest.java

示例12: initLogback

import ch.qos.logback.classic.PatternLayout; //导入方法依赖的package包/类
public static void initLogback() {
    LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();

    StatusManager statusManager = loggerContext.getStatusManager();
    if (statusManager != null) {
        statusManager.add(new InfoStatus("Setting up logger configuration.", loggerContext));
    }

    final PatternLayout layout = new PatternLayout();
    layout.setContext(loggerContext);
    layout.setPattern("%msg%n");
    layout.start();

    AppenderBase<ILoggingEvent> appender = new AppenderBase<ILoggingEvent>() {
        @Override
        protected void append(ILoggingEvent event) {
            String message = layout.doLayout(event);
            LogHelper.appendLogEntry(event.getTimeStamp(), convertLevel(event.getLevel()),
                    event.getLoggerName(), event.getThreadName(), message);
        }
    };
    appender.setContext(loggerContext);
    appender.setName(LOGBACK_APPENDER_NAME);
    appender.start();

    Logger rootLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
    rootLogger.addAppender(appender);
}
 
开发者ID:noveogroup,项目名称:clap,代码行数:29,代码来源:LogbackHelper.java

示例13: configureLogging

import ch.qos.logback.classic.PatternLayout; //导入方法依赖的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();
}
 
开发者ID:Kloudtek,项目名称:kloudmake,代码行数:19,代码来源:Cli.java

示例14: createAppender

import ch.qos.logback.classic.PatternLayout; //导入方法依赖的package包/类
private FlumeAppender createAppender(final Agent... agents) {
  PatternLayout layout = new PatternLayout();
  layout.setContext(ctx);
  layout.setPattern("%d{yyyy-MM-dd HH:mm:ss} %c [%p] %m%n");
  layout.start();

  final FlumeAppender avroAppender = new FlumeAppender();
  if (null == agents || agents.length == 0) {
    avroAppender.addAgent(Agent.create("localhost", testPort));
  } else {
    for (Agent agent : agents) {
      avroAppender.addAgent(agent);
    }
  }
  avroAppender.setCompressBody(true);
  avroAppender.setType("avro");
  avroAppender.setLayout(layout);
  avroAppender.setName("FlumeAppender");
  avroAppender.start();
  return avroAppender;
}
 
开发者ID:jopecko,项目名称:logback-flume-ng,代码行数:22,代码来源:FlumeAppenderTest.java

示例15: start

import ch.qos.logback.classic.PatternLayout; //导入方法依赖的package包/类
@Override
public void start() {
	patternLayout = new PatternLayout();
	patternLayout.setContext(getContext());
	patternLayout.setPattern("[`%d{HH:mm:ss}`] [`%t/%level`] [`%logger{0}`]: %msg");
	patternLayout.start();

	super.start();
}
 
开发者ID:Mantaro,项目名称:MantaroRPG,代码行数:10,代码来源:DiscordLogBack.java


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