本文整理汇总了Java中org.apache.log4j.spi.AppenderAttachable类的典型用法代码示例。如果您正苦于以下问题:Java AppenderAttachable类的具体用法?Java AppenderAttachable怎么用?Java AppenderAttachable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AppenderAttachable类属于org.apache.log4j.spi包,在下文中一共展示了AppenderAttachable类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: findLayoutAppender
import org.apache.log4j.spi.AppenderAttachable; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Appender findLayoutAppender(Enumeration<? extends Appender> appenders) {
if(appenders == null) {
return null;
}
while (appenders.hasMoreElements()) {
Appender appender = appenders.nextElement();
// get the first appender with this layout instance and ignore others;
// actually a single instance of this class is not intended to be used with multiple threads.
if (appender.getLayout() == this) {
return appender;
}
if (appender instanceof AppenderAttachable) {
AppenderAttachable appenderContainer = (AppenderAttachable) appender;
return findLayoutAppender(appenderContainer.getAllAppenders());
}
}
return null;
}
开发者ID:szhem,项目名称:log4j-json-layout,代码行数:21,代码来源:LogStashJsonLayout.java
示例2: closeNestedAppenders
import org.apache.log4j.spi.AppenderAttachable; //导入依赖的package包/类
/**
Close all attached appenders implementing the AppenderAttachable
interface.
@since 1.0
*/
synchronized
void closeNestedAppenders() {
Enumeration enumeration = this.getAllAppenders();
if(enumeration != null) {
while(enumeration.hasMoreElements()) {
Appender a = (Appender) enumeration.nextElement();
if(a instanceof AppenderAttachable) {
a.close();
}
}
}
}
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:18,代码来源:Category.java
示例3: parseAppender
import org.apache.log4j.spi.AppenderAttachable; //导入依赖的package包/类
/**
Used internally to parse an appender element.
*/
protected
Appender parseAppender (Element appenderElement) {
String className = subst(appenderElement.getAttribute(CLASS_ATTR));
LogLog.debug("Class name: [" + className+']');
try {
Object instance = Loader.loadClass(className).newInstance();
Appender appender = (Appender)instance;
PropertySetter propSetter = new PropertySetter(appender);
appender.setName(subst(appenderElement.getAttribute(NAME_ATTR)));
NodeList children = appenderElement.getChildNodes();
final int length = children.getLength();
for (int loop = 0; loop < length; loop++) {
Node currentNode = children.item(loop);
/* We're only interested in Elements */
if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
Element currentElement = (Element)currentNode;
// Parse appender parameters
if (currentElement.getTagName().equals(PARAM_TAG)) {
setParameter(currentElement, propSetter);
}
// Set appender layout
else if (currentElement.getTagName().equals(LAYOUT_TAG)) {
appender.setLayout(parseLayout(currentElement));
}
// Add filters
else if (currentElement.getTagName().equals(FILTER_TAG)) {
parseFilters(currentElement, appender);
}
else if (currentElement.getTagName().equals(ERROR_HANDLER_TAG)) {
parseErrorHandler(currentElement, appender);
}
else if (currentElement.getTagName().equals(APPENDER_REF_TAG)) {
String refName = subst(currentElement.getAttribute(REF_ATTR));
if(appender instanceof AppenderAttachable) {
AppenderAttachable aa = (AppenderAttachable) appender;
LogLog.debug("Attaching appender named ["+ refName+
"] to appender named ["+ appender.getName()+"].");
aa.addAppender(findAppenderByReference(currentElement));
} else {
LogLog.error("Requesting attachment of appender named ["+
refName+ "] to appender named ["+ appender.getName()+
"] which does not implement org.apache.log4j.spi.AppenderAttachable.");
}
} else {
parseUnrecognizedElement(instance, currentElement, props);
}
}
}
propSetter.activate();
return appender;
}
/* Yes, it's ugly. But all of these exceptions point to the same
problem: we can't create an Appender */
catch (Exception oops) {
LogLog.error("Could not create an Appender. Reported error follows.",
oops);
return null;
}
}
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:68,代码来源:DOMConfigurator.java
示例4: parseAppender
import org.apache.log4j.spi.AppenderAttachable; //导入依赖的package包/类
/**
Used internally to parse an appender element.
*/
protected
Appender parseAppender (Element appenderElement) {
String className = subst(appenderElement.getAttribute(CLASS_ATTR));
LogLog.debug("Class name: [" + className+']');
try {
Object instance = Loader.loadClass(className).newInstance();
Appender appender = (Appender)instance;
PropertySetter propSetter = new PropertySetter(appender);
appender.setName(subst(appenderElement.getAttribute(NAME_ATTR)));
NodeList children = appenderElement.getChildNodes();
final int length = children.getLength();
for (int loop = 0; loop < length; loop++) {
Node currentNode = children.item(loop);
/* We're only interested in Elements */
if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
Element currentElement = (Element)currentNode;
// Parse appender parameters
if (currentElement.getTagName().equals(PARAM_TAG)) {
setParameter(currentElement, propSetter);
}
// Set appender layout
else if (currentElement.getTagName().equals(LAYOUT_TAG)) {
appender.setLayout(parseLayout(currentElement));
}
// Add filters
else if (currentElement.getTagName().equals(FILTER_TAG)) {
parseFilters(currentElement, appender);
}
else if (currentElement.getTagName().equals(ERROR_HANDLER_TAG)) {
parseErrorHandler(currentElement, appender);
}
else if (currentElement.getTagName().equals(APPENDER_REF_TAG)) {
String refName = subst(currentElement.getAttribute(REF_ATTR));
if(appender instanceof AppenderAttachable) {
AppenderAttachable aa = (AppenderAttachable) appender;
LogLog.debug("Attaching appender named ["+ refName+
"] to appender named ["+ appender.getName()+"].");
aa.addAppender(findAppenderByReference(currentElement));
} else {
LogLog.error("Requesting attachment of appender named ["+
refName+ "] to appender named ["+ appender.getName()+
"] which does not implement org.apache.log4j.spi.AppenderAttachable.");
}
} else {
parseUnrecognizedElement(instance, currentElement, props);
}
}
}
propSetter.activate();
return appender;
}
/* Yes, it's ugly. But all of these exceptions point to the same
problem: we can't create an Appender */
catch (Exception oops) {
if (oops instanceof InterruptedException || oops instanceof InterruptedIOException) {
Thread.currentThread().interrupt();
}
LogLog.error("Could not create an Appender. Reported error follows.",
oops);
return null;
}
}
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:71,代码来源:DOMConfigurator.java
注:本文中的org.apache.log4j.spi.AppenderAttachable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论