Overview
This guide shows you how to send the logs of a Spring Boot application to SigNoz with OpenTelemetry. Each log that your application writes during a request carries the trace_id and the span_id of that request, so you can go from a log to its trace in SigNoz.
Prerequisites
- A Spring Boot 3 or 4 application that logs with Logback (the Spring Boot default) or Log4j 2
- Java 17 or later
- An instance of SigNoz (either Cloud or Self-Hosted)
Tested with Java 21, Spring Boot 3.5.16, 4.0.10, and 4.2.0, and OpenTelemetry Java instrumentation 2.34.0 (the Java agent and the Spring Boot starter).
Send logs to SigNoz
Pick one of two setups. Both send logs, traces, and the correlation between them.
- OpenTelemetry Java agent (recommended): You attach a JAR file when you start the application. You do not change the code or the build.
- OpenTelemetry Spring Boot starter: You add a dependency to the build. Use it when you cannot attach an agent, for example in a GraalVM native image. It captures Logback logs only. For Log4j 2, use the Java agent.
Step 1. Download the Java agent
curl -L -O https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jarOn Windows, run this in PowerShell instead:
Invoke-WebRequest -Uri "https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar" -OutFile "opentelemetry-javaagent.jar"Step 2. Run the application with the agent
Set the environment variables, then start the application with the -javaagent flag before -jar:
export OTEL_SERVICE_NAME="<service-name>"
export OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.<region>.signoz.cloud:443"
export OTEL_EXPORTER_OTLP_HEADERS="signoz-ingestion-key=<your-ingestion-key>"
export OTEL_METRICS_EXPORTER="none"
java -javaagent:./opentelemetry-javaagent.jar -jar <path-to-your-app-jar>Add the agent to your image and start the application with it:
FROM eclipse-temurin:21-jre
WORKDIR /app
ADD https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar /app/opentelemetry-javaagent.jar
COPY <path-to-your-app-jar> /app/app.jar
ENTRYPOINT ["java", "-javaagent:/app/opentelemetry-javaagent.jar", "-jar", "/app/app.jar"]Build the image and run the container with the environment variables:
docker build -t <your-app> .
docker run -p 8080:8080 \
-e OTEL_SERVICE_NAME="<service-name>" \
-e OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.<region>.signoz.cloud:443" \
-e OTEL_EXPORTER_OTLP_HEADERS="signoz-ingestion-key=<your-ingestion-key>" \
-e OTEL_METRICS_EXPORTER="none" \
<your-app>Build the image from the Docker tab and push it to a registry that your cluster can pull from. Then set the environment variables in your Deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
name: <your-app>
spec:
replicas: 1
selector:
matchLabels:
app: <your-app>
template:
metadata:
labels:
app: <your-app>
spec:
containers:
- name: <your-app>
image: <your-app>
ports:
- containerPort: 8080
env:
- name: OTEL_SERVICE_NAME
value: "<service-name>"
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: "https://ingest.<region>.signoz.cloud:443"
- name: OTEL_EXPORTER_OTLP_HEADERS
value: "signoz-ingestion-key=<your-ingestion-key>"
- name: OTEL_METRICS_EXPORTER
value: "none"Apply it:
kubectl apply -f deployment.yamlIn PowerShell, set the environment variables, then start the application with the -javaagent flag before -jar:
$env:OTEL_SERVICE_NAME = "<service-name>"
$env:OTEL_EXPORTER_OTLP_ENDPOINT = "https://ingest.<region>.signoz.cloud:443"
$env:OTEL_EXPORTER_OTLP_HEADERS = "signoz-ingestion-key=<your-ingestion-key>"
$env:OTEL_METRICS_EXPORTER = "none"
java -javaagent:.\opentelemetry-javaagent.jar -jar <path-to-your-app-jar>Verify these values:
<service-name>: The name of your application in SigNoz, for exampleinventory-service.<region>: Your SigNoz Cloud region.<your-ingestion-key>: Your ingestion key.<path-to-your-app-jar>: The path to your application JAR file. Maven builds it intarget/, and Gradle builds it inbuild/libs/.<your-app>: The name of your image and Deployment. In the Kubernetes Deployment,imageis the full image reference in your registry, for exampleregistry.example.com/inventory-service:1.0.
The agent captures the logs from Logback and Log4j 2. OTEL_METRICS_EXPORTER="none" turns off metrics. Keep traces on, because log correlation needs them.
Step 1. Add the dependencies
Add the OpenTelemetry BOM and the starter to your build.
Add the BOM before any other BOM in dependencyManagement:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-instrumentation-bom</artifactId>
<version>2.34.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>Then add the starter to dependencies:
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-spring-boot-starter</artifactId>
</dependency>Import the BOM with the io.spring.dependency-management plugin, which Spring Initializr adds to Gradle projects:
dependencyManagement {
imports {
mavenBom("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom:2.34.0")
}
}
dependencies {
implementation("io.opentelemetry.instrumentation:opentelemetry-spring-boot-starter")
}Do not import the BOM with implementation(platform(...)) in a build that uses this plugin. The plugin then keeps the older OpenTelemetry versions from Spring Boot, and the application fails at startup with ClassNotFoundException: io.opentelemetry.common.ComponentLoader.
Step 2. Set the environment variables and run the application
export OTEL_SERVICE_NAME="<service-name>"
export OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.<region>.signoz.cloud:443"
export OTEL_EXPORTER_OTLP_HEADERS="signoz-ingestion-key=<your-ingestion-key>"
export OTEL_METRICS_EXPORTER="none"
java -jar <path-to-your-app-jar>In PowerShell:
$env:OTEL_SERVICE_NAME = "<service-name>"
$env:OTEL_EXPORTER_OTLP_ENDPOINT = "https://ingest.<region>.signoz.cloud:443"
$env:OTEL_EXPORTER_OTLP_HEADERS = "signoz-ingestion-key=<your-ingestion-key>"
$env:OTEL_METRICS_EXPORTER = "none"
java -jar <path-to-your-app-jar>Verify these values:
<service-name>: The name of your application in SigNoz, for exampleinventory-service. If you leave it out, andOTEL_RESOURCE_ATTRIBUTESdoes not setservice.name, the starter usesspring.application.name.<region>: Your SigNoz Cloud region.<your-ingestion-key>: Your ingestion key.<path-to-your-app-jar>: The path to your application JAR file. Maven builds it intarget/, and Gradle builds it inbuild/libs/.
The starter adds an OpenTelemetry appender to Logback when the application starts. You do not change logback.xml or logback-spring.xml. The starter does not capture Log4j 2 logs.
Step 3. Print the trace ID in console logs (optional)
When your application logs during a request, OpenTelemetry adds the trace_id and the span_id of the request to the log in SigNoz. You do not change your logging code. To also print the trace ID in the console logs, add it to the log pattern in application.properties:
logging.pattern.level=%5p [trace_id=%X{trace_id} span_id=%X{span_id}]A console log line then looks like this:
2026-11-26T07:54:50.694Z INFO [trace_id=0e001aeaef6a07cfad06ea2df281601a span_id=01718e09540161dc] 1 --- [order-service] [nio-8080-exec-1] com.example.orders.OrderController : Order 42 placedValidate
- Send a few requests to your application.
- In SigNoz, open Logs and filter by
service.name = <service-name>. - Click a log that your application wrote during a request. Make sure that the log details show a TRACE ID and a SPAN ID.
- Click the TRACE ID. SigNoz opens the trace of the request in a new tab.


Production tips
- Log levels: Set the level of noisy loggers in
application.properties, for examplelogging.level.org.springframework=WARN. OpenTelemetry sends only the logs that pass the Logback level. - Sensitive data: Do not log passwords, tokens, or personal data. Do not put them in MDC, because OpenTelemetry can send MDC values as log attributes.
- Attributes: Each extra log attribute adds a key that SigNoz indexes. Capture MDC or key-value attributes only when you query them.
- Trace sampling: A sampler reduces traces, not logs. A log from a request that the sampler dropped still has a
trace_id, but SigNoz has no trace for it.
Setup OpenTelemetry Collector (Optional)
The OpenTelemetry Collector is a service that receives telemetry from your application and forwards it to SigNoz. Use it when you want to filter or enrich logs before they leave your servers, or when the Collector must handle batching and retries for many applications.
To send logs through a Collector, set OTEL_EXPORTER_OTLP_ENDPOINT to the OTLP/HTTP receiver of the Collector, for example http://<collector-host>:4318, and remove OTEL_EXPORTER_OTLP_HEADERS. The Collector adds the ingestion key when it exports to SigNoz.
See Switch from direct export to Collector for the full steps, and Why use the OpenTelemetry Collector? for more context.
Troubleshooting
Still not seeing data in SigNoz? Work through Debug missing traces, logs, and metrics.
Logs do not appear in SigNoz
- Likely cause: a wrong endpoint or ingestion key. With a wrong key, the application console shows
Failed to export ... logs. Server responded with HTTP status code 401. - Fix: Make sure that
OTEL_EXPORTER_OTLP_ENDPOINTishttps://ingest.<region>.signoz.cloud:443with your region, and thatOTEL_EXPORTER_OTLP_HEADERShas your ingestion key. Make sure thatOTEL_LOGS_EXPORTERis not set tonone. - Verify: Restart the application and send a request. The
Failed to exportwarnings stop, and the logs appear in the Logs Explorer.
The agent does not start
-
Likely cause: the
-javaagentflag comes after-jar. The JVM then passes the flag to your application, and the agent does not load. The application starts, but the console shows no lines that start with[otel.javaagent. -
Fix: Put the
-javaagentflag before-jar:# Correct java -javaagent:./opentelemetry-javaagent.jar -jar <path-to-your-app-jar> # Wrong: the agent does not load java -jar <path-to-your-app-jar> -javaagent:./opentelemetry-javaagent.jar -
Verify: The console shows
opentelemetry-javaagent - version:when the application starts.
Logs do not appear with the starter and Log4j 2
- Likely cause: the Spring Boot starter captures Logback logs only. With Log4j 2, the starter sends traces, but no logs.
- Fix: Use the Java agent instead of the starter. The agent captures Log4j 2 logs.
- Verify: Restart the application with the agent and send a request. The logs appear in the Logs Explorer with a TRACE ID.
Logs appear without trace_id or span_id
- Likely cause: the application wrote the log outside a traced operation. Logs from application startup and from background threads without a span have no
trace_id. - Fix: No fix is needed for these logs. A log gets a
trace_idonly when the application writes it during a traced operation, such as an HTTP request. - Verify: Send a request to your application. The logs that it writes during the request have a TRACE ID in the log details.
Next Steps
- Send traces from Java and Spring Boot to learn more about the agent and its configuration.
- Send logs from other Java applications with the agent or the OpenTelemetry SDK.
- Read the Spring Boot logging guide for log levels, log groups, and structured logging.
- Query your logs in the Logs Explorer.
Get Help
If you need help with the steps in this topic, please reach out to us on SigNoz Community Slack. If you are a SigNoz Cloud user, please use in product chat support located at the bottom right corner of your SigNoz instance or contact us at cloud-support@signoz.io.