我在项目中使用log4j 1.2.17时遇到了"StackOverflow"错误。
以下是错误的堆栈跟踪
java.lang.StackOverflowError
at org.apache.log4j.PatternLayout.format(PatternLayout.java:506)
at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:310)
at org.apache.log4j.WriterAppender.append(WriterAppender.java:162)
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
at org.apache.log4j.Category.callAppenders(Category.java:206)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.debug(Category.java:260)
at com.java.oauth.client.JavaOauthWithCertificate.ReadRequiredConfigurationsToObtainToken(JavaOauthWithCertificate.java:42)
at com.java.oauth.client.JavaOauthWithCertificate.getTokenByCertificate(JavaOauthWithCertificate.java:112)
at com.test.sre.service.ServiceWrapperImpl.logMessage(ServiceWrapperImpl.java:54)
at com.test.sre.logging.SREWebServiceAppender.append(SREWebServiceAppender.java:59)
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
at org.apache.log4j.Category.callAppenders(Category.java:206)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.debug(Category.java:260)
at com.java.oauth.client.JavaOauthWithCertificate.ReadRequiredConfigurationsToObtainToken(JavaOauthWithCertificate.java:42)
at com.java.oauth.client.JavaOauthWithCertificate.getTokenByCertificate(JavaOauthWithCertificate.java:112)
第42行ReadRequiredConfigurationsToObtainToken中的代码部分是
记录器. debug(验证已开始)
SRE Web服务附加器正在将日志写入数据库。这将调用扩展的AppenderSkeleton类以实现自定义附加器。当代码运行时,执行在此点卡住,并在特定时间后引发错误。
我已经尝试增加JVM的堆栈大小和堆大小,但还没有成功。
下面是在属性文件中设置的log4j配置
log4j.rootLogger=DEBUG, A1, A2, A3
# service will ignore this output, but somebody manually running might be interested
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=[%d] %-5p %c %x - %m%n
# also log to a file - again probably not monitored in production but might be handy for debugging
log4j.appender.A2=org.apache.log4j.DailyRollingFileAppender
log4j.appender.A2.File=C:\\EnergyTrading\\logs\\debug.log
log4j.appender.A2.DatePattern='.'yyyy-MM-dd
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=[%d] %-5p %c %x - %m%n
#web service appender - directs log messages to
log4j.appender.A3=com.test.sre.logging.SREWebServiceAppender
Any help on this error would be greatly helpful.
1条答案
按热度按时间qco9c6ql1#
看起来您的appender
SREWebServiceAppender
正在使用JavaOauthWithCertificate
,而JavaOauthWithCertificate
正在使用log4j进行日志记录。这样日志记录将导致更多日志记录,并且总是以堆栈溢出结束。您应该更新日志记录配置。您可以执行以下操作之一(从最明智到最不明智):
log4j.appender.A3=com.test.sre.logging.SREWebServiceAppender
中记录调试消息()com.java.oauth.client.JavaOauthWithCertificate.ReadRequiredConfigurationsToObtainToken
中的DEBUG消息(我不知道这些是什么类别)log4j.appender.A3=com.test.sre.logging.SREWebServiceAppender