ch.qos.logback.core.rolling.RollingFileAppender.setLayout()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(147)

本文整理了Java中ch.qos.logback.core.rolling.RollingFileAppender.setLayout方法的一些代码示例,展示了RollingFileAppender.setLayout的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RollingFileAppender.setLayout方法的具体详情如下:
包路径:ch.qos.logback.core.rolling.RollingFileAppender
类名称:RollingFileAppender
方法名:setLayout

RollingFileAppender.setLayout介绍

暂无

代码示例

代码示例来源:origin: alibaba/nacos

protected ch.qos.logback.core.Appender getLogbackDailyRollingFileAppender(String productName, String file,
                                     String encoding) {
  RollingFileAppender appender = new RollingFileAppender();
  appender.setContext(LogbackLoggerContextUtil.getLoggerContext());
  appender.setName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender");
  appender.setAppend(true);
  appender.setFile(LoggerHelper.getLogFile(productName, file));
  TimeBasedRollingPolicy rolling = new TimeBasedRollingPolicy();
  rolling.setParent(appender);
  rolling.setFileNamePattern(LoggerHelper.getLogFile(productName, file) + ".%d{yyyy-MM-dd}");
  rolling.setContext(LogbackLoggerContextUtil.getLoggerContext());
  rolling.start();
  appender.setRollingPolicy(rolling);
  PatternLayout layout = new PatternLayout();
  layout.setPattern(LoggerHelper.getPattern(productName));
  layout.setContext(LogbackLoggerContextUtil.getLoggerContext());
  layout.start();
  appender.setLayout(layout);
  // 启动
  appender.start();
  return appender;
}

代码示例来源:origin: alibaba/nacos

layout.setContext(LogbackLoggerContextUtil.getLoggerContext());
layout.start();
appender.setLayout(layout);

代码示例来源:origin: alibaba/nacos

layout.setContext(LogbackLoggerContextUtil.getLoggerContext());
layout.start();
appender.setLayout(layout);

代码示例来源:origin: stackoverflow.com

static {
  try {
    String logFileName = "neo4j.log";
    RollingFileAppender fa = new RollingFileAppender();
    fa.setName("NEO4JLOGGER");
    fa.setFile(logFileName);
    fa.setLayout(new PatternLayout(
        "[%d{dd.MM.yyyy HH:mm:ss.SSS}]  %5p %c{1}:%L - %m%n"));
    fa.setAppend(true);
    fa.activateOptions();
    Logger.getLogger("CLASSES NEEDED TO BE LOGGED").setLevel(Level.ALL);
    Logger.getLogger("CLASSES NEEDED TO BE LOGGED").addAppender(fa);

  } catch (Exception ex) {
    logger.error("Intialize Logger :: Failed...  \n   ", ex);
  }
}

代码示例来源:origin: stackoverflow.com

public Logger generateLogger(String parent, String name, String logDirectory, String filePattern, String fileThreshold) {
  // TODO Auto-generated method stub

  //Create Logger 
      String loggerName = parent + "." + name;
      Logger log = Logger.getLogger(loggerName);

      //Create Logging File Appender
      RollingFileAppender fileApp = new RollingFileAppender();
      fileApp.setName("Broker." + loggerName + "_FileAppender");
      fileApp.setFile(logDirectory +"/"+ name+".log");
      fileApp.setLayout(new PatternLayout(filePattern));
      fileApp.setThreshold(Level.toLevel(fileThreshold));
      fileApp.setAppend(true);
      fileApp.activateOptions();

      log.addAppender(fileApp);

      return log;     
}

代码示例来源:origin: stackoverflow.com

appender.setLayout(layOut);

代码示例来源:origin: stackoverflow.com

private Logger logger = null;
private RollingFileAppender appender = null;

private void init(String NameForAppender, String Name4LogFile) {
  logger = Logger.getLogger(NameForAppender); //NOT DEFAULT BY "logger = Logger.getLogger(TestJob.class);"

  appender = new RollingFileAppender();
  appender.setName(NameForAppender); //<-- I think this helps in pair of the Logger.getLogger(NameForAppender) above
  appender.setLayout(new PatternLayout("%d{yyyy-MM-dd/HH:mm:ss.SSS/zzz} %-5p %c{1}:%L - %m%n"));
  appender.setFile(Name4LogFile);
  appender.setAppend(true);
  appender.setImmediateFlush(true);
  appender.setMaxFileSize("100MB");
  appender.setMaxBackupIndex(10);
  appender.activateOptions();

  logger.setAdditivity(false);    //<--do not use default root logger
  logger.addAppender(appender);
}

代码示例来源:origin: stackoverflow.com

static
{
  if (null == LOGGER.getAppender("TEST_LOG_APPENDER"))
  {
    RollingFileAppender fa = new RollingFileAppender();
    fa.setName("TEST_LOG_APPENDER");
    fa.setFile("/test-output/" + "App_1.log");
    fa.setLayout(new PatternLayout("%d %-5p [%c{1}] %m%n"));
    fa.setThreshold(Level.DEBUG);
    fa.setAppend(true);
    fa.setMaxFileSize("10MB");
    fa.activateOptions();
    LOGGER.addAppender(fa);
  }
}

代码示例来源:origin: stackoverflow.com

logger = Logger.getLogger(TestJob.class);
appender = new RollingFileAppender();
appender.setLayout(new PatternLayout("%d %-5p %c{1}:%L - %m%n"));
appender.setFile("logs/trh1/log1.txt");
appender.setAppend(false);

代码示例来源:origin: com.alibaba.nacos/nacos-client

protected ch.qos.logback.core.Appender getLogbackDailyRollingFileAppender(String productName, String file,
                                     String encoding) {
  RollingFileAppender appender = new RollingFileAppender();
  appender.setContext(LogbackLoggerContextUtil.getLoggerContext());
  appender.setName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender");
  appender.setAppend(true);
  appender.setFile(LoggerHelper.getLogFile(productName, file));
  TimeBasedRollingPolicy rolling = new TimeBasedRollingPolicy();
  rolling.setParent(appender);
  rolling.setFileNamePattern(LoggerHelper.getLogFile(productName, file) + ".%d{yyyy-MM-dd}");
  rolling.setContext(LogbackLoggerContextUtil.getLoggerContext());
  rolling.start();
  appender.setRollingPolicy(rolling);
  PatternLayout layout = new PatternLayout();
  layout.setPattern(LoggerHelper.getPattern(productName));
  layout.setContext(LogbackLoggerContextUtil.getLoggerContext());
  layout.start();
  appender.setLayout(layout);
  // 启动
  appender.start();
  return appender;
}

代码示例来源:origin: com.taobao.middleware/logger.core

protected ch.qos.logback.core.Appender getLogbackDailyRollingFileAppender(String productName, String file,
                                     String encoding) {
  RollingFileAppender appender = new RollingFileAppender();
  appender.setContext(LogbackLoggerContextUtil.getLoggerContext());
  appender.setName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender");
  appender.setAppend(true);
  appender.setFile(LoggerHelper.getLogFile(productName, file));
  TimeBasedRollingPolicy rolling = new TimeBasedRollingPolicy();
  rolling.setParent(appender);
  rolling.setFileNamePattern(LoggerHelper.getLogFile(productName, file) + ".%d{yyyy-MM-dd}");
  rolling.setContext(LogbackLoggerContextUtil.getLoggerContext());
  rolling.start();
  appender.setRollingPolicy(rolling);
  PatternLayout layout = new PatternLayout();
  layout.setPattern(LoggerHelper.getPattern(productName));
  layout.setContext(LogbackLoggerContextUtil.getLoggerContext());
  layout.start();
  appender.setLayout(layout);
  // 启动
  appender.start();
  return appender;
}

代码示例来源:origin: com.alibaba.edas.acm/acm-sdk

protected ch.qos.logback.core.Appender getLogbackDailyRollingFileAppender(String productName, String file,
                                     String encoding) {
  RollingFileAppender appender = new RollingFileAppender();
  appender.setContext(LogbackLoggerContextUtil.getLoggerContext());
  appender.setName(productName + "." + file.replace(File.separatorChar, '.') + ".Appender");
  appender.setAppend(true);
  appender.setFile(LoggerHelper.getLogFile(productName, file));
  TimeBasedRollingPolicy rolling = new TimeBasedRollingPolicy();
  rolling.setParent(appender);
  rolling.setFileNamePattern(LoggerHelper.getLogFile(productName, file) + ".%d{yyyy-MM-dd}");
  rolling.setContext(LogbackLoggerContextUtil.getLoggerContext());
  rolling.start();
  appender.setRollingPolicy(rolling);
  PatternLayout layout = new PatternLayout();
  layout.setPattern(LoggerHelper.getPattern(productName));
  layout.setContext(LogbackLoggerContextUtil.getLoggerContext());
  layout.start();
  appender.setLayout(layout);
  // 启动
  appender.start();
  return appender;
}

代码示例来源:origin: com.teradata.airlift/http-server

fileAppender.setFile(filename);
fileAppender.setAppend(true);
fileAppender.setLayout(httpLogLayout);
fileAppender.setRollingPolicy(rollingPolicy);
fileAppender.start();

代码示例来源:origin: com.taobao.middleware/logger.core

layout.setContext(LogbackLoggerContextUtil.getLoggerContext());
layout.start();
appender.setLayout(layout);

代码示例来源:origin: com.alibaba.nacos/nacos-client

layout.setContext(LogbackLoggerContextUtil.getLoggerContext());
layout.start();
appender.setLayout(layout);

代码示例来源:origin: com.alibaba.edas.acm/acm-sdk

layout.setContext(LogbackLoggerContextUtil.getLoggerContext());
layout.start();
appender.setLayout(layout);

代码示例来源:origin: com.alibaba.nacos/nacos-client

layout.setContext(LogbackLoggerContextUtil.getLoggerContext());
layout.start();
appender.setLayout(layout);

代码示例来源:origin: com.alibaba.edas.acm/acm-sdk

layout.setContext(LogbackLoggerContextUtil.getLoggerContext());
layout.start();
appender.setLayout(layout);

代码示例来源:origin: com.taobao.middleware/logger.core

layout.setContext(LogbackLoggerContextUtil.getLoggerContext());
layout.start();
appender.setLayout(layout);

代码示例来源:origin: com.plausiblelabs.warwizard/warwizard-core

appender.setAppend(true);
appender.setContext(context);
appender.setLayout(formatter);
appender.setFile(file.getCurrentLogFilename());
appender.setPrudent(false);

相关文章