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


Java Appender.getLayout方法代码示例

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


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

示例1: enableRingBufferAppender

import org.apache.log4j.Appender; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static void enableRingBufferAppender(Logger logger, int bufferSize) {
    Layout l = null;
    if (LOG.isDebugEnabled())
        LOG.debug(logger + " => " + logger.getAllAppenders());
    for (Object o : CollectionUtil.iterable(logger.getAllAppenders())) {
        Appender a = (Appender)o;
        l = a.getLayout();
    } // FOR
    if (l != null) {
        logger.removeAllAppenders();
        logger.addAppender(new RingBufferAppender(bufferSize));
        Logger.getRootLogger().info("Enabled RingBuffer logging for '" + logger.getName() + "'");
    }        
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:16,代码来源:RingBufferAppender.java

示例2: printOptions

import org.apache.log4j.Appender; //导入方法依赖的package包/类
protected
void printOptions(PrintWriter out, Category cat) {
  Enumeration appenders = cat.getAllAppenders();
  Level prio = cat.getLevel();
  String appenderString = (prio == null ? "" : prio.toString());
  
  while (appenders.hasMoreElements()) {
    Appender app = (Appender) appenders.nextElement();
    String name;
    
    if ((name = (String) appenderNames.get(app)) == null) {
    
      // first assign name to the appender
      if ((name = app.getName()) == null || isGenAppName(name)) {
          name = genAppName();
      }
      appenderNames.put(app, name);
      
      printOptions(out, app, "log4j.appender."+name);
      if (app.getLayout() != null) {
        printOptions(out, app.getLayout(), "log4j.appender."+name+".layout");
      }
    }
    appenderString += ", " + name;
  }
  String catKey = (cat == Logger.getRootLogger())
      ? "log4j.rootLogger"
      : "log4j.logger." + cat.getName();
  if (appenderString != "") {
    out.println(catKey + "=" + appenderString);
  }
  if (!cat.getAdditivity() && cat != Logger.getRootLogger()) {
  	out.println("log4j.additivity." + cat.getName() + "=false");    
  }
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:36,代码来源:PropertyPrinter.java

示例3: FileAppender

import org.apache.log4j.Appender; //导入方法依赖的package包/类
public FileAppender() {

        setLayout(new PatternLayout("[%d{ISO8601} %-5p] %m%n"));

        // trying to get a layout from log4j configuration
        Enumeration<?> en = Logger.getRootLogger().getAllAppenders();
        if (en != null && en.hasMoreElements()) {
            Appender app = (Appender) en.nextElement();
            if (app != null && app.getLayout() != null) {
                Logger.getRootLogger().debug("Retrieved layout from log4j configuration");
                setLayout(app.getLayout());
            }
        }
    }
 
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:15,代码来源:FileAppender.java

示例4: printOptions

import org.apache.log4j.Appender; //导入方法依赖的package包/类
/**
 * @since 1.2.15
 */
protected
void printOptions(PrintWriter out, Category cat) {
  Enumeration appenders = cat.getAllAppenders();
  Level prio = cat.getLevel();
  String appenderString = (prio == null ? "" : prio.toString());
  
  while (appenders.hasMoreElements()) {
    Appender app = (Appender) appenders.nextElement();
    String name;
    
    if ((name = (String) appenderNames.get(app)) == null) {
    
      // first assign name to the appender
      if ((name = app.getName()) == null || isGenAppName(name)) {
          name = genAppName();
      }
      appenderNames.put(app, name);
      
      printOptions(out, app, "log4j.appender."+name);
      if (app.getLayout() != null) {
        printOptions(out, app.getLayout(), "log4j.appender."+name+".layout");
      }
    }
    appenderString += ", " + name;
  }
  String catKey = (cat == Logger.getRootLogger())
      ? "log4j.rootLogger"
      : "log4j.logger." + cat.getName();
  if (appenderString != "") {
    out.println(catKey + "=" + appenderString);
  }
  if (!cat.getAdditivity() && cat != Logger.getRootLogger()) {
  	out.println("log4j.additivity." + cat.getName() + "=false");    
  }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:39,代码来源:PropertyPrinter.java

示例5: createOBRLogger

import org.apache.log4j.Appender; //导入方法依赖的package包/类
/**
 * This create log4j logger for OBS work flow using root logger.
 * It adds file appender with specified filename to the logger which creates separate
 * log file for each resource access tool.
 *
 * @param clazz
 * @param logFile String containing name of log file.
 * @return log4j Logger object
 */
@SuppressWarnings("unchecked")
public static Logger createOBRLogger(Class clazz) {

    Logger logger = Logger.getLogger(clazz);

    Enumeration<Appender> appenders = Logger.getRootLogger()
            .getAllAppenders();
    // Add all appenders of root logger
    while (appenders.hasMoreElements()) {
        Appender appender = appenders.nextElement();

        //	For file appender create new appender with different log file
        if (appender instanceof RollingFileAppender) {
            try {
                // Creates new file appender
                RollingFileAppender newFileAppender = new RollingFileAppender(
                        appender.getLayout(), FileResourceParameters.resourceLogFolder() + OBR_LOG_FILE
                );
                newFileAppender.activateOptions();

                logger.addAppender(newFileAppender);

            } catch (Exception e) {
                e.printStackTrace();
            }
        } else {
            logger.addAppender(appender);
        }
    }

    logger.setAdditivity(false);

    return logger;

}
 
开发者ID:ncbo,项目名称:resource_access_tools,代码行数:45,代码来源:LoggerUtils.java

示例6: createOBRLogger

import org.apache.log4j.Appender; //导入方法依赖的package包/类
/**
 * This create log4j logger for OBS work flow using root logger.
 * It adds file appender with specified filename to the logger which creates separate
 * log file for each resource access tool.
 *
 * @param clazz
 * @param logFile String containing name of log file.
 * @return log4j Logger object
 */
@SuppressWarnings("unchecked")
public static Logger createOBRLogger(Class clazz) {

    Logger logger = Logger.getLogger(clazz);

    Enumeration<Appender> appenders = Logger.getRootLogger()
            .getAllAppenders();
    // Add all appenders of root logger
    while (appenders.hasMoreElements()) {
        Appender appender = appenders.nextElement();

        //	For file appender create new appender with different log file
        if (appender instanceof DailyRollingFileAppender) {
            try {
                // Creates new file appender
                DailyRollingFileAppender newFileAppender = new DailyRollingFileAppender(
                        appender.getLayout(), FileParameters.obrLogFolder() + OBR_LOG_FILE,
                        ((DailyRollingFileAppender) appender)
                                .getDatePattern());
                newFileAppender.activateOptions();

                logger.addAppender(newFileAppender);

            } catch (Exception e) {
                e.printStackTrace();
            }
        } else {
            logger.addAppender(appender);
        }
    }

    logger.setAdditivity(false);

    return logger;

}
 
开发者ID:ncbo,项目名称:resource_access_tools,代码行数:46,代码来源:LoggerUtils.java

示例7: LogCapturer

import org.apache.log4j.Appender; //导入方法依赖的package包/类
private LogCapturer(Logger logger) {
  this.logger = logger;
  Appender defaultAppender = Logger.getRootLogger().getAppender("stdout");
  if (defaultAppender == null) {
    defaultAppender = Logger.getRootLogger().getAppender("console");
  }
  final Layout layout = (defaultAppender == null) ? new PatternLayout() :
      defaultAppender.getLayout();
  this.appender = new WriterAppender(layout, sw);
  logger.addAppender(this.appender);
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:12,代码来源:GenericTestUtils.java


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