diff --git a/docs/platforms/java/common/legacy/log4j2/index.mdx b/docs/platforms/java/common/legacy/log4j2/index.mdx index cd6107535abf2..ede3ada320bb5 100644 --- a/docs/platforms/java/common/legacy/log4j2/index.mdx +++ b/docs/platforms/java/common/legacy/log4j2/index.mdx @@ -9,7 +9,7 @@ An [updated Java SDK](/platforms/java/) SDK supersedes this deprecated version. -The `sentry-log4j2` library provides [Log4j 2.x](https://logging.apache.org/log4j/2.x/) support for Sentry via an [Appender](https://logging.apache.org/log4j/2.x/log4j-core/apidocs/org/apache/logging/log4j/core/Appender.html) that sends logged exceptions to Sentry. Once this integration is configured you can _also_ use Sentry’s static API, [as shown on the usage page](/platforms/java/legacy/usage), in order to do things like record breadcrumbs, set the current user, or manually send events. +The `sentry-log4j2` library provides [Log4j 2](https://logging.apache.org/log4j/2.x/) support for Sentry via an [Appender](https://logging.apache.org/log4j/2.x/log4j-core/apidocs/org/apache/logging/log4j/core/Appender.html) that sends logged exceptions to Sentry. Once this integration is configured you can _also_ use Sentry’s static API, [as shown on the usage page](/platforms/java/legacy/usage), in order to do things like record breadcrumbs, set the current user, or manually send events. The source can be found [on GitHub](https://github.com/getsentry/sentry-java/tree/master/sentry-log4j2). @@ -41,23 +41,24 @@ Example configuration using the `log4j2.xml` format: ```xml - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + ``` Next, **you’ll need to configure your DSN** (client key) and optionally other values such as `environment` and `release`. [See the configuration page](/platforms/java/legacy/configuration/#setting-the-dsn) for ways you can do this. diff --git a/docs/platforms/java/guides/spring-boot/logging-frameworks.mdx b/docs/platforms/java/guides/spring-boot/logging-frameworks.mdx index 158feee074897..446b26caf9943 100644 --- a/docs/platforms/java/guides/spring-boot/logging-frameworks.mdx +++ b/docs/platforms/java/guides/spring-boot/logging-frameworks.mdx @@ -65,9 +65,9 @@ However, if errors that may appear during startup should to be sent to Sentry, t -### Log4j2 +### Log4j 2 -To use Sentry's Log4j2 integration in Spring Boot application, you must include a dependency to the `sentry-log4j2` module: +To use Sentry's Log4j 2 integration in Spring Boot application, you must include a dependency to the `sentry-log4j2` module: ```xml {tabTitle:Maven} @@ -87,30 +87,33 @@ libraryDependencies += "io.sentry" % "sentry-log4j2" % "{{@inject packages.versi For other dependency managers see the [central Maven repository](https://search.maven.org/artifact/io.sentry/sentry-log4j2). -Then [follow the guide on configuring Log4j2 with Spring Boot](https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto-configure-log4j-for-logging) and configure `SentryAppender` in the `log4j2.xml` file: +Then [follow the guide on configuring Log4j 2 with Spring Boot](https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto-configure-log4j-for-logging) and configure `SentryAppender` in the `log4j2.xml` file: ```xml - - - - - - - - - - - - - + + + + + + + + + + + + + + + + ``` -You do not need to configure your DSN in the Log4j2 configuration file since Sentry is configured from the Spring Boot integration. +You do not need to configure your DSN in the Log4j 2 configuration file since Sentry is configured from the Spring Boot integration. -However, if errors that may appear during startup should to be sent to Sentry, the DSN must be provided to both the Log4j2 and Spring Boot configurations. +However, if errors that may appear during startup should to be sent to Sentry, the DSN must be provided to both the Log4j 2 and Spring Boot configurations. diff --git a/platform-includes/configuration/decluttering/java.mdx b/platform-includes/configuration/decluttering/java.mdx index c0a5c2859af15..a1d1facdb9f2b 100644 --- a/platform-includes/configuration/decluttering/java.mdx +++ b/platform-includes/configuration/decluttering/java.mdx @@ -1 +1 @@ -When used together with one of the logging framework integrations, the Java SDK captures all error logs as events. If you see a particular kind of error very often that has a `logger` tag, you can ignore that particular logger entirely. For more information see our Logback or Log4j 2.x integration. +When used together with one of the logging framework integrations, the Java SDK captures all error logs as events. If you see a particular kind of error very often that has a `logger` tag, you can ignore that particular logger entirely. For more information see our Logback or Log4j 2 integration. diff --git a/platform-includes/getting-started-config/java.log4j2.mdx b/platform-includes/getting-started-config/java.log4j2.mdx index 396370971bb92..a115456c1fba5 100644 --- a/platform-includes/getting-started-config/java.log4j2.mdx +++ b/platform-includes/getting-started-config/java.log4j2.mdx @@ -6,36 +6,35 @@ The `ConsoleAppender` is provided only as an example of a non-Sentry appender se - ```xml - - - - - - - - - - - - - + + + + + + + + + + + + + + + + ``` -`SentryAppender` does not support Log4j2's [async mode](https://logging.apache.org/log4j/2.x/manual/async.html). The Sentry Java SDK itself is already asynchronous and does not perform any blocking operation on the calling thread. +`SentryAppender` does not support [Log4j's asynchronous loggers](https://logging.apache.org/log4j/2.x/manual/async.html). The Sentry Java SDK itself is already asynchronous and does not perform any blocking operation on the calling thread. ### DSN Configuration -Note that **you need to configure your DSN** (client key) only if you wish to initialize the SDK through the log4j2 integration. If you're planning to use `Sentry.init` to provide configuration, such as by using the `beforeSend` callback, you **should not** provide the DSN in both `Sentry.init` and the appender configuration; just leave it out of the appender configuration in this case. - +Note that **you need to configure your DSN** (client key) only if you wish to initialize the SDK through the Log4j 2 integration. If you're planning to use `Sentry.init` to provide configuration, such as by using the `beforeSend` callback, you **should not** provide the DSN in both `Sentry.init` and the appender configuration; just leave it out of the appender configuration in this case. ```xml - + ``` If the DSN is not present in the `log4j2.xml` configuration, Sentry will attempt to read it from the system property `sentry.dsn`, environment variable `SENTRY_DSN` or the `dsn` property in `sentry.properties` file. [See the configuration page](/platforms/java/configuration/) for more details on external configuration. @@ -59,9 +58,8 @@ Breadcrumbs are kept in memory (by default the last 100 records) and are sent wi ```xml - + minimumEventLevel="WARN"/> ``` diff --git a/public/_platforms/java.json b/public/_platforms/java.json index 71ac9ec47e16f..d3c1088cfd7a1 100644 --- a/public/_platforms/java.json +++ b/public/_platforms/java.json @@ -1 +1 @@ -{"key":"java","type":"language","doc_link":"https://docs.sentry.io/platforms/java/","name":"Java","aliases":[],"categories":["desktop","server"],"body":"\n Sentry for Java is a collection of modules provided by Sentry; it supports Java 1.8 and above. At its core, Sentry for Java provides a raw client for sending events to Sentry. If you use Spring Boot, Spring, Logback, or Log4j2, we recommend visiting our Sentry Java documentation for installation instructions.\n\n

Install

\n

Install the SDK via Gradle, Maven, or SBT:

\n

Gradle

\n

For Gradle, add to your build.gradle file:

\n
// Make sure mavenCentral is there.\nrepositories {\n    mavenCentral()\n}\n\n// Add Sentry's SDK as a dependency.\ndependencies {\n    implementation 'io.sentry:sentry:7.3.0'\n}
\n

To upload your source code to Sentry so it can be shown in stack traces, use our Gradle plugin.

\n
buildscript {\n    repositories {\n        mavenCentral()\n    }\n}\n\nplugins {\n    id \"io.sentry.jvm.gradle\" version \"4.2.0\"\n}\n\nsentry {\n    // Generates a JVM (Java, Kotlin, etc.) source bundle and uploads your source code to Sentry.\n    // This enables source context, allowing you to see your source\n    // code as part of your stack traces in Sentry.\n    includeSourceContext = true\n\n    org = \"___ORG_SLUG___\"\n    projectName = \"___PROJECT_SLUG___\"\n    authToken = \"your-sentry-auth-token\"\n}
\n

Maven

\n

For Maven, add to your pom.xml file:

\n
<dependency>\n    <groupId>io.sentry</groupId>\n    <artifactId>sentry</artifactId>\n    <version>7.3.0</version>\n</dependency>
\n

To upload your source code to Sentry so it can be shown in stack traces, use our Maven plugin.

\n
<build>\n    <plugins>\n        <plugin>\n            <groupId>io.sentry</groupId>\n            <artifactId>sentry-maven-plugin</artifactId>\n            <version>0.0.2</version>\n            <configuration>\n                <!-- for showing output of sentry-cli -->\n                <debugSentryCli>true</debugSentryCli>\n\n                <!-- download the latest sentry-cli and provide path to it here -->\n                <!-- download it here: https://github.com/getsentry/sentry-cli/releases -->\n                <!-- minimum required version is 2.17.3 -->\n                <sentryCliExecutablePath>/path/to/sentry-cli</sentryCliExecutablePath>\n\n                <org>___ORG_SLUG___</org>\n\n                <project>___PROJECT_SLUG___</project>\n\n                <!-- in case you're self hosting, provide the URL here -->\n                <!--<url>http://localhost:8000/</url>-->\n\n                <!-- provide your auth token via SENTRY_AUTH_TOKEN environment variable -->\n                <!-- you can find it in Sentry UI: Settings > Account > API > Auth Tokens -->\n                <authToken>${env.SENTRY_AUTH_TOKEN}</authToken>\n            </configuration>\n            <executions>\n                <execution>\n                    <phase>generate-resources</phase>\n                    <goals>\n                        <goal>uploadSourceBundle</goal>\n                    </goals>\n                </execution>\n            </executions>\n        </plugin>\n    </plugins>\n    ...\n</build>
\n

SBT

\n

For SBT:

\n
libraryDependencies += \"io.sentry\" % \"sentry\" % \"7.3.0\"
\n

To upload your source code to Sentry so it can be shown in stack traces, please refer to Manually Uploading Source Context.

\n

Configure

\n

Configure Sentry as soon as possible in your application's lifecycle:

\n
import io.sentry.Sentry;\n\nSentry.init(options -> {\n  options.setDsn(\"___PUBLIC_DSN___\");\n  // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n  // We recommend adjusting this value in production.\n  options.setTracesSampleRate(1.0);\n  // When first trying Sentry it's good to see what the SDK is doing:\n  options.setDebug(true);\n});
\n

Send First Event

\n

Trigger your first event from your development environment by intentionally creating an error with the Sentry#captureException method, to test that everything is working:

\n
import java.lang.Exception;\nimport io.sentry.Sentry;\n\ntry {\n  throw new Exception(\"This is a test.\");\n} catch (Exception e) {\n  Sentry.captureException(e);\n}
\n

If you're new to Sentry, use the email alert to access your account and complete a product tour.

\n

If you're an existing user and have disabled alerts, you won't receive this email.

\n

Measure performance

\n

You can capture transactions using the SDK. For example:

\n
import io.sentry.ITransaction;\nimport io.sentry.Sentry;\nimport io.sentry.SpanStatus;\n\n// A good name for the transaction is key, to help identify what this is about\nITransaction transaction = Sentry.startTransaction(\"processOrderBatch()\", \"task\");\ntry {\n  processOrderBatch();\n} catch (Exception e) {\n  transaction.setThrowable(e);\n  transaction.setStatus(SpanStatus.INTERNAL_ERROR);\n  throw e;\n} finally {\n  transaction.finish();\n}
\n

For more information about the API and automatic instrumentations included in the SDK, visit the docs.

"} +{"key":"java","type":"language","doc_link":"https://docs.sentry.io/platforms/java/","name":"Java","aliases":[],"categories":["desktop","server"],"body":"\n Sentry for Java is a collection of modules provided by Sentry; it supports Java 1.8 and above. At its core, Sentry for Java provides a raw client for sending events to Sentry. If you use Spring Boot, Spring, Logback, or Log4j 2, we recommend visiting our Sentry Java documentation for installation instructions.\n\n

Install

\n

Install the SDK via Gradle, Maven, or SBT:

\n

Gradle

\n

For Gradle, add to your build.gradle file:

\n
// Make sure mavenCentral is there.\nrepositories {\n    mavenCentral()\n}\n\n// Add Sentry's SDK as a dependency.\ndependencies {\n    implementation 'io.sentry:sentry:7.3.0'\n}
\n

To upload your source code to Sentry so it can be shown in stack traces, use our Gradle plugin.

\n
buildscript {\n    repositories {\n        mavenCentral()\n    }\n}\n\nplugins {\n    id \"io.sentry.jvm.gradle\" version \"4.2.0\"\n}\n\nsentry {\n    // Generates a JVM (Java, Kotlin, etc.) source bundle and uploads your source code to Sentry.\n    // This enables source context, allowing you to see your source\n    // code as part of your stack traces in Sentry.\n    includeSourceContext = true\n\n    org = \"___ORG_SLUG___\"\n    projectName = \"___PROJECT_SLUG___\"\n    authToken = \"your-sentry-auth-token\"\n}
\n

Maven

\n

For Maven, add to your pom.xml file:

\n
<dependency>\n    <groupId>io.sentry</groupId>\n    <artifactId>sentry</artifactId>\n    <version>7.3.0</version>\n</dependency>
\n

To upload your source code to Sentry so it can be shown in stack traces, use our Maven plugin.

\n
<build>\n    <plugins>\n        <plugin>\n            <groupId>io.sentry</groupId>\n            <artifactId>sentry-maven-plugin</artifactId>\n            <version>0.0.2</version>\n            <configuration>\n                <!-- for showing output of sentry-cli -->\n                <debugSentryCli>true</debugSentryCli>\n\n                <!-- download the latest sentry-cli and provide path to it here -->\n                <!-- download it here: https://github.com/getsentry/sentry-cli/releases -->\n                <!-- minimum required version is 2.17.3 -->\n                <sentryCliExecutablePath>/path/to/sentry-cli</sentryCliExecutablePath>\n\n                <org>___ORG_SLUG___</org>\n\n                <project>___PROJECT_SLUG___</project>\n\n                <!-- in case you're self hosting, provide the URL here -->\n                <!--<url>http://localhost:8000/</url>-->\n\n                <!-- provide your auth token via SENTRY_AUTH_TOKEN environment variable -->\n                <!-- you can find it in Sentry UI: Settings > Account > API > Auth Tokens -->\n                <authToken>${env.SENTRY_AUTH_TOKEN}</authToken>\n            </configuration>\n            <executions>\n                <execution>\n                    <phase>generate-resources</phase>\n                    <goals>\n                        <goal>uploadSourceBundle</goal>\n                    </goals>\n                </execution>\n            </executions>\n        </plugin>\n    </plugins>\n    ...\n</build>
\n

SBT

\n

For SBT:

\n
libraryDependencies += \"io.sentry\" % \"sentry\" % \"7.3.0\"
\n

To upload your source code to Sentry so it can be shown in stack traces, please refer to Manually Uploading Source Context.

\n

Configure

\n

Configure Sentry as soon as possible in your application's lifecycle:

\n
import io.sentry.Sentry;\n\nSentry.init(options -> {\n  options.setDsn(\"___PUBLIC_DSN___\");\n  // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n  // We recommend adjusting this value in production.\n  options.setTracesSampleRate(1.0);\n  // When first trying Sentry it's good to see what the SDK is doing:\n  options.setDebug(true);\n});
\n

Send First Event

\n

Trigger your first event from your development environment by intentionally creating an error with the Sentry#captureException method, to test that everything is working:

\n
import java.lang.Exception;\nimport io.sentry.Sentry;\n\ntry {\n  throw new Exception(\"This is a test.\");\n} catch (Exception e) {\n  Sentry.captureException(e);\n}
\n

If you're new to Sentry, use the email alert to access your account and complete a product tour.

\n

If you're an existing user and have disabled alerts, you won't receive this email.

\n

Measure performance

\n

You can capture transactions using the SDK. For example:

\n
import io.sentry.ITransaction;\nimport io.sentry.Sentry;\nimport io.sentry.SpanStatus;\n\n// A good name for the transaction is key, to help identify what this is about\nITransaction transaction = Sentry.startTransaction(\"processOrderBatch()\", \"task\");\ntry {\n  processOrderBatch();\n} catch (Exception e) {\n  transaction.setThrowable(e);\n  transaction.setStatus(SpanStatus.INTERNAL_ERROR);\n  throw e;\n} finally {\n  transaction.finish();\n}
\n

For more information about the API and automatic instrumentations included in the SDK, visit the docs.

"} diff --git a/public/_platforms/kotlin.json b/public/_platforms/kotlin.json index feb0309a60317..60fcdef5109d1 100644 --- a/public/_platforms/kotlin.json +++ b/public/_platforms/kotlin.json @@ -1 +1 @@ -{"key":"kotlin","type":"language","doc_link":"https://docs.sentry.io/platforms/kotlin/","name":"Kotlin","aliases":[],"categories":["mobile","desktop","server"],"body":"\nSentry supports Kotlin for both JVM and Android. This wizard guides you through set up in the JVM scenario.\n

If you're interested in Android, head over to the Getting Started for that SDK instead. At its core, Sentry for Java provides a raw client for sending events to Sentry. If you use Spring Boot, Spring, Logback, JUL, or Log4j2, head over to our Getting Started for Sentry Java.\n

\n

Install

\n

Install the SDK via Gradle or Maven:

\n

For Gradle, add to your build.gradle file:

\n
// Make sure mavenCentral is there.\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    implementation 'io.sentry:sentry:7.3.0'\n}
\n

For Maven, add to your pom.xml file:

\n
<dependency>\n    <groupId>io.sentry</groupId>\n    <artifactId>sentry</artifactId>\n    <version>7.3.0</version>\n</dependency>
\n

Configure

\n

Configure Sentry as soon as possible in your application's lifecycle:

\n
import io.sentry.Sentry\n\nSentry.init { options ->\n  options.dsn = \"___PUBLIC_DSN___\"\n  // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n  // We recommend adjusting this value in production.\n  options.tracesSampleRate = 1.0\n  // When first trying Sentry it's good to see what the SDK is doing:\n  options.isDebug = true\n}
\n

Send First Event

\n

Trigger your first event from your development environment by intentionally creating an error with the Sentry#captureException method, to test that everything is working:

\n
import java.lang.Exception\nimport io.sentry.Sentry\n\ntry {\n  throw Exception(\"This is a test.\")\n} catch (e: Exception) {\n  Sentry.captureException(e)\n}
\n

If you're new to Sentry, use the email alert to access your account and complete a product tour.

\n

If you're an existing user and have disabled alerts, you won't receive this email.

\n

Measure Performance

\n

You can capture transactions using the SDK. For example:

\n
import io.sentry.Sentry\nimport io.sentry.SpanStatus\n\n// A good name for the transaction is key, to help identify what this is about\nval transaction = Sentry.startTransaction(\"processOrderBatch()\", \"task\")\ntry {\n  processOrderBatch()\n} catch (e: Exception) {\n  transaction.throwable = e\n  transaction.status = SpanStatus.INTERNAL_ERROR\n  throw e\n} finally {\n  transaction.finish();\n}
\n

For more information about the API and automatic instrumentations included in the SDK, visit the docs.

"} +{"key":"kotlin","type":"language","doc_link":"https://docs.sentry.io/platforms/kotlin/","name":"Kotlin","aliases":[],"categories":["mobile","desktop","server"],"body":"\nSentry supports Kotlin for both JVM and Android. This wizard guides you through set up in the JVM scenario.\n

If you're interested in Android, head over to the Getting Started for that SDK instead. At its core, Sentry for Java provides a raw client for sending events to Sentry. If you use Spring Boot, Spring, Logback, JUL, or Log4j 2, head over to our Getting Started for Sentry Java.\n

\n

Install

\n

Install the SDK via Gradle or Maven:

\n

For Gradle, add to your build.gradle file:

\n
// Make sure mavenCentral is there.\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    implementation 'io.sentry:sentry:7.3.0'\n}
\n

For Maven, add to your pom.xml file:

\n
<dependency>\n    <groupId>io.sentry</groupId>\n    <artifactId>sentry</artifactId>\n    <version>7.3.0</version>\n</dependency>
\n

Configure

\n

Configure Sentry as soon as possible in your application's lifecycle:

\n
import io.sentry.Sentry\n\nSentry.init { options ->\n  options.dsn = \"___PUBLIC_DSN___\"\n  // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n  // We recommend adjusting this value in production.\n  options.tracesSampleRate = 1.0\n  // When first trying Sentry it's good to see what the SDK is doing:\n  options.isDebug = true\n}
\n

Send First Event

\n

Trigger your first event from your development environment by intentionally creating an error with the Sentry#captureException method, to test that everything is working:

\n
import java.lang.Exception\nimport io.sentry.Sentry\n\ntry {\n  throw Exception(\"This is a test.\")\n} catch (e: Exception) {\n  Sentry.captureException(e)\n}
\n

If you're new to Sentry, use the email alert to access your account and complete a product tour.

\n

If you're an existing user and have disabled alerts, you won't receive this email.

\n

Measure Performance

\n

You can capture transactions using the SDK. For example:

\n
import io.sentry.Sentry\nimport io.sentry.SpanStatus\n\n// A good name for the transaction is key, to help identify what this is about\nval transaction = Sentry.startTransaction(\"processOrderBatch()\", \"task\")\ntry {\n  processOrderBatch()\n} catch (e: Exception) {\n  transaction.throwable = e\n  transaction.status = SpanStatus.INTERNAL_ERROR\n  throw e\n} finally {\n  transaction.finish();\n}
\n

For more information about the API and automatic instrumentations included in the SDK, visit the docs.

"}