我无法创建我的类的实例,因为不知道如何在 log4j.xml 的 createAppender 方法中传递所需的参数。
例外:
ru.appliedtech.desktopapp.client.ui.menu.JTextAreaAppender 中构造函数的参数 0 需要找不到类型为“java.lang.String”的 bean。考虑在您的配置中定义类型为“java.lang.String”的 bean。
@Plugin(name = "JTextAreaAppender", category = "Core", elementType = "appender", printObject = true)
@Configuration
@ComponentScan("ru.appliedtech")
public class JTextAreaAppender extends AbstractAppender
{
private int maxLines = 0;
private static volatile ArrayList<JTextArea> jTextAreaList = new ArrayList<>();
protected JTextAreaAppender(String name, Filter filter, Layout<? extends Serializable> layout, boolean ignoreExceptions, Property[] properties)
{
super(name, filter, layout, ignoreExceptions, properties);
}
@PluginFactory
public static JTextAreaAppender createAppender(@PluginAttribute("name") String name,
@PluginAttribute("ignoreExceptions") boolean ignoreExceptions,
@PluginElement("Layout") Layout<?> layout,
@PluginElement("Filters") Filter filter,
@PluginElement("Properties") Property[] properties) {
return new JTextAreaAppender(name, filter, layout, ignoreExceptions, properties);
}
/**
* add the target JTextArea to be populated and updated by the logging information
* @param textArea text area
*/
public static void addTextArea(final JTextArea textArea) {
JTextAreaAppender.jTextAreaList.add(textArea);
}
@Override
public void append(LogEvent event)
{
//
}
}
log4j.xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="ERROR" packages="ru.appliedtech.desktopapp.client.ui.menu">
<Properties>
<Property name="APP_LOG_ROOT">ru.appliedtech</Property>
</Properties>
holdtom
饮歌长啸
相关分类