本文整理了Java中org.apache.log4j.Appender.setName()
方法的一些代码示例,展示了Appender.setName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Appender.setName()
方法的具体详情如下:
包路径:org.apache.log4j.Appender
类名称:Appender
方法名:setName
[英]Set the name of this appender. The name is used by other components to identify this appender.
[中]设置此追加器的名称。其他组件使用该名称来标识此追加器。
代码示例来源:origin: log4j/log4j
void addAppender(String appenderClass, String appenderName) {
cat.debug("addAppender called with "+appenderClass+", "+appenderName);
Appender appender = (Appender)
OptionConverter.instantiateByClassName(appenderClass,
org.apache.log4j.Appender.class,
null);
appender.setName(appenderName);
logger.addAppender(appender);
//appenderMBeanRegistration();
}
代码示例来源:origin: hawtio/hawtio
@Override
public void reconnectAppender() {
ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory();
boolean added = false;
if (loggerFactory instanceof AppenderAttachable) {
AppenderAttachable appenderAttachable = (AppenderAttachable) loggerFactory;
appender.setName("LogQuery");
appenderAttachable.addAppender(appender);
LOG.info("Connected to Log4j appender to trap logs with hawtio log plugin");
added = true;
}
org.apache.log4j.Logger root = LogManager.getRootLogger();
if (root != null) {
appender.setName("LogQuery");
root.addAppender(appender);
LOG.info("Connected to Log4j appender to trap logs with hawtio log plugin");
added = true;
}
if (!added) {
LOG.warn("No ILoggerFactory or RootLogger found so cannot attach hatwio log appender!");
}
}
代码示例来源:origin: log4j/log4j
PropertySetter propSetter = new PropertySetter(appender);
appender.setName(subst(appenderElement.getAttribute(NAME_ATTR)));
代码示例来源:origin: log4j/log4j
return null;
appender.setName(appenderName);
代码示例来源:origin: cloudfoundry/uaa
@Test
public void logged_exceptions_are_formatted_per_line_when_treating_throwable_as_lines() throws Exception {
ByteArrayOutputStream output = new ByteArrayOutputStream();
LineAwareLayout lineAwareLayout = new LineAwareLayout();
lineAwareLayout.setLineLayout(new PatternLayout("%m" + delimiter));
Appender appender = new WriterAppender(lineAwareLayout, output);
appender.setName("TestLog");
appender.setLayout(lineAwareLayout);
Logger testLogger = LogManager.getLogger("test-logger");
testLogger.addAppender(appender);
testLogger.setLevel(Level.INFO);
Exception ex = new Exception("SOMETHING BAD HAPPEN\nNO REALLY IT'S VERY BAD\n\ntrust me");
ex.setStackTrace(new StackTraceElement[]{new StackTraceElement("CLAZZ", "MEETOD", "FEEL", 123)});
testLogger.info(ex, ex);
String expectedLog = String.join(delimiter, ex.toString().split("\n")) + delimiter + "\tat CLAZZ.MEETOD(FEEL:123)" + delimiter;
assertEquals(expectedLog, output.toString());
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void messages_over_multiple_lines_are_formatted_per_line() throws Exception {
ByteArrayOutputStream output = new ByteArrayOutputStream();
LineAwareLayout lineAwareLayout = new LineAwareLayout();
lineAwareLayout.setLineLayout(new PatternLayout("%m" + delimiter));
Appender appender = new WriterAppender(lineAwareLayout, output);
appender.setName("TestLog");
appender.setLayout(lineAwareLayout);
Logger testLogger = LogManager.getLogger("test-logger");
testLogger.addAppender((appender));
testLogger.setLevel(Level.INFO);
String eventMessage = "test message\nwith\nmultiple lines";
testLogger.info(eventMessage);
String expectedLog = String.join(delimiter, eventMessage.split("\n")) + delimiter;
assertEquals(expectedLog, output.toString());
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void messages_get_the_message_format_applied_after_the_line_format() throws Exception {
ByteArrayOutputStream output = new ByteArrayOutputStream();
String extraLine = "\nTHESE NEWLINES SHOULD NOT GET AFFECTED BY THE LINE FORMAT\n";
LineAwareLayout lineAwareLayout = new LineAwareLayout();
lineAwareLayout.setLineLayout(new PatternLayout("%m" + delimiter));
lineAwareLayout.setMessageLayout(new PatternLayout("%m" + extraLine));
Appender appender = new WriterAppender(lineAwareLayout, output);
appender.setName("TestLog");
appender.setLayout(lineAwareLayout);
Logger testLogger = LogManager.getLogger("test-logger");
testLogger.addAppender((appender));
testLogger.setLevel(Level.INFO);
String eventMessage = "test message\nwith\nmultiple lines";
testLogger.info(eventMessage);
String expectedLog = String.join(delimiter, eventMessage.split("\n")) + delimiter
+ extraLine;
assertEquals(expectedLog, output.toString());
}
代码示例来源:origin: apache/log4j
void addAppender(String appenderClass, String appenderName) {
cat.debug("addAppender called with "+appenderClass+", "+appenderName);
Appender appender = (Appender)
OptionConverter.instantiateByClassName(appenderClass,
org.apache.log4j.Appender.class,
null);
appender.setName(appenderName);
logger.addAppender(appender);
//appenderMBeanRegistration();
}
代码示例来源:origin: camunda/camunda-bpm-platform
PropertySetter propSetter = new PropertySetter(appender);
appender.setName(subst(appenderElement.getAttribute(NAME_ATTR)));
代码示例来源:origin: apache/log4j
PropertySetter propSetter = new PropertySetter(appender);
appender.setName(subst(appenderElement.getAttribute(NAME_ATTR)));
代码示例来源:origin: apache/log4j
return null;
appender.setName(appenderName);
代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl
public void setName(String arg0)
{
m_other.setName(arg0);
}
}
代码示例来源:origin: org.apache.activemq/activemq-all
void addAppender(String appenderClass, String appenderName) {
cat.debug("addAppender called with "+appenderClass+", "+appenderName);
Appender appender = (Appender)
OptionConverter.instantiateByClassName(appenderClass,
org.apache.log4j.Appender.class,
null);
appender.setName(appenderName);
logger.addAppender(appender);
//appenderMBeanRegistration();
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
void addAppender(String appenderClass, String appenderName) {
cat.debug("addAppender called with "+appenderClass+", "+appenderName);
Appender appender = (Appender)
OptionConverter.instantiateByClassName(appenderClass,
org.apache.log4j.Appender.class,
null);
appender.setName(appenderName);
logger.addAppender(appender);
//appenderMBeanRegistration();
}
代码示例来源:origin: camunda/camunda-bpm-platform
return null;
appender.setName(appenderName);
代码示例来源:origin: org.apache.log4j/com.springsource.org.apache.log4j
void addAppender(String appenderClass, String appenderName) {
cat.debug("addAppender called with "+appenderClass+", "+appenderName);
Appender appender = (Appender)
OptionConverter.instantiateByClassName(appenderClass,
org.apache.log4j.Appender.class,
null);
appender.setName(appenderName);
logger.addAppender(appender);
//appenderMBeanRegistration();
}
代码示例来源:origin: org.jboss.logmanager/log4j-jboss-logmanager
void addAppender(String appenderClass, String appenderName) {
cat.debug("addAppender called with "+appenderClass+", "+appenderName);
Appender appender = (Appender)
OptionConverter.instantiateByClassName(appenderClass,
org.apache.log4j.Appender.class,
null);
appender.setName(appenderName);
logger.addAppender(appender);
//appenderMBeanRegistration();
}
代码示例来源:origin: apache-log4j/log4j
void addAppender(String appenderClass, String appenderName) {
cat.debug("addAppender called with "+appenderClass+", "+appenderName);
Appender appender = (Appender)
OptionConverter.instantiateByClassName(appenderClass,
org.apache.log4j.Appender.class,
null);
appender.setName(appenderName);
logger.addAppender(appender);
//appenderMBeanRegistration();
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.log4j
void addAppender(String appenderClass, String appenderName) {
cat.debug("addAppender called with "+appenderClass+", "+appenderName);
Appender appender = (Appender)
OptionConverter.instantiateByClassName(appenderClass,
org.apache.log4j.Appender.class,
null);
appender.setName(appenderName);
logger.addAppender(appender);
//appenderMBeanRegistration();
}
代码示例来源:origin: org.apache/log4j
void addAppender(String appenderClass, String appenderName) {
cat.debug("addAppender called with "+appenderClass+", "+appenderName);
Appender appender = (Appender)
OptionConverter.instantiateByClassName(appenderClass,
org.apache.log4j.Appender.class,
null);
appender.setName(appenderName);
logger.addAppender(appender);
//appenderMBeanRegistration();
}
内容来源于网络,如有侵权,请联系作者删除!