我正在尝试遵循文档,这是我的配置:
dependencies {
// other dependencies here.
compile("log4j:log4j:1.2.7")
compile("io.sentry:sentry-log4j:1.2.2")
}
我的log4j.properties文件:
# Enable the Console and Sentry appenders
log4j.rootLogger=DEBUG, Console, Sentry
# Configure the Console appender
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
# Configure the Sentry appender, overriding the logging threshold to the WARN level
log4j.appender.Sentry=io.sentry.log4j.SentryAppender
log4j.appender.Sentry.threshold=WARN
运行我的应用时,我收到此错误:
java.lang.NoSuchMethodError: org.apache.log4j.spi.LoggingEvent.getTimeStamp()J
at io.sentry.log4j.SentryAppender.createEventBuilder(SentryAppender.java:101) ~[sentry-log4j-1.2.2.jar:na]
at io.sentry.log4j.SentryAppender.append(SentryAppender.java:84) ~[sentry-log4j-1.2.2.jar:na]
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:221) ~[log4j-1.2.7.jar:1.2.7]
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:57) ~[log4j-1.2.7.jar:na]
at org.apache.log4j.Category.callAppenders(Category.java:187) ~[log4j-1.2.7.jar:1.2.7]
at org.apache.log4j.Category.forcedLog(Category.java:372) ~[log4j-1.2.7.jar:1.2.7]
at org.apache.log4j.Category.error(Category.java:286) ~[log4j-1.2.7.jar:1.2.7]
我做错了什么?我只是按照这里的文档:https://docs.sentry.io/clients/java/modules/log4j/
答案 0 :(得分:0)
看起来你正在将自己固定到对于sentry-java
而言太旧的log4j版本,你可以尝试删除你的log4j依赖关系(并让sentry-java
接管)或升级它?
sentry-java
正在使用1.2.17
:https://github.com/getsentry/sentry-java/blob/master/sentry-log4j/pom.xml#L18