我制作了自己的附加程序:
class MyAppender : public AppenderSkeleton
{...
void MyAppender ::append(const spi::LoggingEventPtr& event, Pool& p)
{
LogString log;
log4cxx::helpers::Pool pool;
printf("test\n");
getLayout()->format(log, event, pool);
...
}
...
boolean requiresLayout(){return false; }
...
}
我还通过 log4j 配置文件添加了它:
log4j.appender.MYAPPND=org.apache.log4j.MyAppender
log4j.appender.MYAPPND.layout=org.apache.log4j.PatternLayout
log4j.appender.MYAPPND.layout.ConversionPattern=%d{ISO8601} %d{%Z} [%-5p] [%t] [%c] [%C{1}.%M(%L)] - %m%n
log4j.logger.file.name = DEBUG, MYAPPND
在 getLayout()->format(log, event, pool) {segmentation fault} 之前它工作得很好。有什么帮助吗?