File tree Expand file tree Collapse file tree 4 files changed +13
-6
lines changed
sentry-samples/sentry-samples-jul
java/io/sentry/samples/jul Expand file tree Collapse file tree 4 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ object Config {
5252 val androidxRecylerView = " androidx.recyclerview:recyclerview:1.2.1"
5353
5454 val slf4jApi = " org.slf4j:slf4j-api:1.7.30"
55+ val slf4jJdk14 = " org.slf4j:slf4j-jdk14:1.7.30"
5556 val logbackVersion = " 1.2.9"
5657 val logbackClassic = " ch.qos.logback:logback-classic:$logbackVersion "
5758
Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ plugins {
88
99application {
1010 mainClass.set(" io.sentry.samples.jul.Main" )
11- applicationDefaultJvmArgs = mutableListOf (" -Djava.util.logging.config.file=${project.projectDir} /src/main/resources/logging.properties" )
1211}
1312
1413configure<JavaPluginExtension > {
@@ -18,5 +17,5 @@ configure<JavaPluginExtension> {
1817
1918dependencies {
2019 implementation(projects.sentryJul)
21- implementation(Config .Libs .logbackClassic )
20+ implementation(Config .Libs .slf4jJdk14 )
2221}
Original file line number Diff line number Diff line change 22
33import java .util .UUID ;
44import java .util .logging .Level ;
5+ import java .util .logging .LogManager ;
56import java .util .logging .Logger ;
67import org .slf4j .MDC ;
78
89public class Main {
910
1011 private static final Logger LOGGER = Logger .getLogger (Main .class .getName ());
1112
12- public static void main (String [] args ) {
13+ public static void main (String [] args ) throws Exception {
14+ // instead of the following line you can also pass
15+ // -Djava.util.logging.config.file=.../logging.properties to the
16+ // java command
17+ LogManager .getLogManager ()
18+ .readConfiguration (Main .class .getClassLoader ().getResourceAsStream ("logging.properties" ));
1319 LOGGER .config ("Hello Sentry!" );
1420
1521 // MDC parameters are converted to Sentry Event tags
1622 MDC .put ("userId" , UUID .randomUUID ().toString ());
23+ MDC .put ("requestId" , UUID .randomUUID ().toString ());
1724
1825 // logging arguments are converted to Sentry Event parameters
1926 LOGGER .log (Level .INFO , "User has made a purchase of product: %d" , 445 );
Original file line number Diff line number Diff line change 1- io.sentry.jul.SentryHandler.minimumEventLevel =INFO
1+ io.sentry.jul.SentryHandler.minimumEventLevel =DEBUG
22io.sentry.jul.SentryHandler.minimumBreadcrumbLevel =CONFIG
33io.sentry.jul.SentryHandler.printfStyle =true
44io.sentry.jul.SentryHandler.level =CONFIG
5- io.sentry.samples.jul.Main. handlers =io.sentry.jul.SentryHandler
6- io.sentry.samples.jul.Main. level =CONFIG
5+ handlers =io.sentry.jul.SentryHandler
6+ level =CONFIG
You can’t perform that action at this time.
0 commit comments