本文整理汇总了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);
}
}
示例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");
}
}
示例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;
}
示例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");
}
}