5

I use Sentry (on premise) for our logging. Recently I started moving to the Spring framework, I am not able to get the logs hit Sentry servers. I tried using log4j and logger (slf4j). In both cases I was not able to make any progress. My assumption is that since I use spring-starter maven dependency, it includes logger by default, while all documentation on Sentry + Java mentions using raven. Probably my log configurations are not read because of this. Can anybody tell me how can I get sentry working on my Spring project?

EDIT: Here is my logback.xml which is in classpath.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <appender name="Sentry" class="net.kencochrane.raven.logback.SentryAppender">
        <dsn>
            http://xxx@example.com/sentry/2
        </dsn>
    </appender>

    <root level="error">
        <appender-ref ref="Sentry" />
    </root>
</configuration>
Codevalley
  • 4,593
  • 7
  • 42
  • 56
  • By adding [this](https://github.com/getsentry/raven-java/blob/master/raven-logback/README.md#maven) dependency and add the [`SentryAppender`](https://github.com/getsentry/raven-java/blob/master/raven-logback/README.md#configuration) to your logback configuration. – M. Deinum Sep 03 '15 at 13:48
  • I did that. I followed the same example. But I am not getting any of my logs hitting Sentry servers. My question is spring-boot-starter already includes logger dependency. Raven also adds logger dependency, is this creating a conflict? http://docs.spring.io/spring-boot/docs/current/reference/html/howto-logging.html – Codevalley Sep 03 '15 at 13:50
  • No. Where have you configured it, in which file? Also make sure that you are actually using the logger, only adding the appender isn't going to do much... Post your `logback.xml`. – M. Deinum Sep 03 '15 at 13:55
  • Added my logback.xml to the question. – Codevalley Sep 03 '15 at 14:01
  • Currently you are only logging errors, so everything logged at other levels (info, warn) will not be logged. Also make sure that the `logback.xml` is in the root of your classpath (it should be directly in `src/main/resources`). Also check [this](http://docs.spring.io/spring-boot/docs/current/reference/html/howto-logging.html#howto-configure-logback-for-loggin). – M. Deinum Sep 03 '15 at 14:05
  • I checked that too. In fact I tried to send a dummy `log.error()` just to see if I can hit the servers. But not happening. – Codevalley Sep 03 '15 at 14:25
  • But is it in the root of the classpath? Also please add the include as mentioned in the link, and add the the `CONSOLE` appender see if logging is written to the console. Also are you sure you are using logback and not some other logging? – M. Deinum Sep 03 '15 at 17:37
  • Also try to start your application with `--debug` which should give you more logging and you might want to add `debug="true"` to the `configuration` element of the logback.xml. That way, if the file is read, you should get some more detailed information. – M. Deinum Sep 03 '15 at 17:49

0 Answers0