Giter VIP home page Giter VIP logo

Comments (6)

edbras avatar edbras commented on June 11, 2024 1

Thanks for your answer:

Is there a reason, you're calling Sentry.init manually? You should be able to set the logger, e.g. by exposing a

That was also my question in the Sentry issue tracker, as I did not want to call it as I was afraid that my env/properties were ignored when calling that, which was also the case I think. That is how we landed here on Github to get more help.

The code you are suggesting, looks like the correct way to do it, I will give a try later, thanks.

from sentry-java.

romtsn avatar romtsn commented on June 11, 2024

That's because we always set the logger to the System.out when debug is configured, see here:

options.setLogger(new SystemOutLogger());

They would have to provide a custom ILogger implementation which writes into the same file they use for log4j

from sentry-java.

edbras avatar edbras commented on June 11, 2024

I did set the options, but noticed it's complaining...
As I posted in your ticket system:

@Configuration
@Slf4j
public class SentryConfiguration {
    @EventListener(ApplicationStartedEvent.class)
    void configureSentry() {
        Sentry.init(options -> {
            log.info("Configuring Sentry");
            options.setEnableExternalConfiguration(true);
            options.setLogger(new SentryLogger());
        });
    }
}

```}

I don't think it's using anymore the EVn and application.yml settings, as it's complaining that the DNS is not set and I should set an empty string. But that already happens through the application.yml, but even dot I indicate it should load external properties, it is already complaining during this call.

Can you post me an example that works please?

from sentry-java.

Fwang36 avatar Fwang36 commented on June 11, 2024

Hey @edbras ,

I got this to work in my test app. The DSN does have to be provided to the Sentry.init() for this to work. The other options can still be provided externally, but only through environment variables. Setting the other options in either the application.properties or application.yml both caused it to stop working. Also, if I provide the DSN as an environment option as well, it also stopped working. This is my setup that works for me to output the debug logging to a file.

		Sentry.init(options -> {
			options.setEnableExternalConfiguration(true);
			options.setDsn("https://[email protected]/4504181117091840");
			options.setLogger(new Log4jSentryLogger());
		  });
export SENTRY_DEBUG=true
export SENTRY_TRACES_SAMPLE_RATE=1.0

from sentry-java.

adinauer avatar adinauer commented on June 11, 2024

Is there a reason, you're calling Sentry.init manually? You should be able to set the logger, e.g. by exposing a Sentry.OptionsConfiguration<SentryOptions> bean that'll let you customize options programatically without having to fall back to manual init.

@Bean
public Sentry.OptionsConfiguration<SentryOptions> optionsConfiguration() {
    return options -> {
      options.setLogger(new Log4jSentryLogger());
    };
}

from sentry-java.

adinauer avatar adinauer commented on June 11, 2024

We're closing this now as it seems everyone has got it to work. Feel free to reopen if you need more help.

from sentry-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.