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


Java Appender.getName方法代码示例

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


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

示例1: registerAppenderMBean

import org.apache.log4j.Appender; //导入方法依赖的package包/类
void registerAppenderMBean(Appender appender) {
  String name = appender.getName();
  cat.debug("Adding AppenderMBean for appender named "+name);
  ObjectName objectName = null;
  try {
    AppenderDynamicMBean appenderMBean = new AppenderDynamicMBean(appender);
    objectName = new ObjectName("log4j", "appender", name);
    if (!server.isRegistered(objectName)) {
      server.registerMBean(appenderMBean, objectName);
      dAttributes.add(new MBeanAttributeInfo("appender=" + name, "javax.management.ObjectName",
              "The " + name + " appender.", true, true, false));
    }

  } catch(Exception e) {
    cat.error("Could not add appenderMBean for ["+name+"].", e);
  }
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:18,代码来源:LoggerDynamicMBean.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: getAppenderName

import org.apache.log4j.Appender; //导入方法依赖的package包/类
/**
   * Get MBean name.
   * @param appender appender, may not be null.
   * @return name.
   * @since 1.2.16
   */
static protected String getAppenderName(final Appender appender){
    String name = appender.getName();
    if (name == null || name.trim().length() == 0) {
        // try to get some form of a name, because null is not allowed (exception), and empty string certainly isn't useful in JMX..
        name = appender.toString();
    }
    return name;
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:15,代码来源:AbstractDynamicMBean.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


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