简体   繁体   中英

Error while configuring Sentry for logging with log4j2

I have the following logging xml config

<Configuration>
  <Appenders>
    <Console name="CONSOLE" target="SYSTEM_OUT">
        <PatternLayout pattern="{some pattern}"/>
    </Console>
    <Raven name="Sentry">
        <dsn>
            https://{public key}@app.getsentry.com/65532?options
        </dsn>
        <tags>
            tag1:value1,tag2:value2
        </tags>
    </Raven>
    <Async name="ASYNC">
        <AppenderRef ref="CONSOLE" level="${sys:console_log_level}"/>
        <AppenderRef ref="Sentry"/>
    </Async>
  </Appenders>

  <Root>
    <AppenderRef ref="ASYNC"/>
  </Root>
</Configuration>

When my logger initializes, I get the following exception>

ERROR Unable to invoke factory method in class class net.kencochrane.raven.log4j2.SentryAppender for element Raven.> 
ERROR appenders Appenders has no parameter that matches element Raven> 
ERROR No appender named Sentry was configured> 

I am running my app on weblogic.

Any help on how to get Sentry working would be appreciated.

This error occurs because you either don't have a static method annotated with @PluginFactory in your plugin or there was a problem calling the method. Looking at the code you should have gotten a stack trace along with the "Unable to invoke" method. What Log4j version are you using?

I would recommend adding status="debug" to the Configuration element and see if any of the debug messages help identify the problem. If that doesn't help please provide the source for your plugin or at least the factory method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM