For the complete documentation index, see llms.txt. Markdown versions are available by appending .md to documentation URLs.

Send Spring Boot Logs to SigNoz Using OpenTelemetry

SigNoz Cloud - This page applies to SigNoz Cloud editions.
Self-Host - This page applies to self-hosted SigNoz editions.

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.jar

On 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>

Verify these values:

  • <service-name>: The name of your application in SigNoz, for example inventory-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 in target/, and Gradle builds it in build/libs/.
  • <your-app>: The name of your image and Deployment. In the Kubernetes Deployment, image is the full image reference in your registry, for example registry.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 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:

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 placed

Validate

  1. Send a few requests to your application.
  2. In SigNoz, open Logs and filter by service.name = <service-name>.
  3. Click a log that your application wrote during a request. Make sure that the log details show a TRACE ID and a SPAN ID.
  4. Click the TRACE ID. SigNoz opens the trace of the request in a new tab.
Logs Explorer filtered by service.name = 'inventory-service', listing INFO and WARN logs from a Spring Boot application
Spring Boot logs in the Logs Explorer, filtered by service name.
Log details for 'Order 94 placed' from inventory-service, with the TRACE ID shown as a link and the SPAN ID next to it
A request log with its trace ID and span ID. Click the trace ID to open the trace.

Production tips

  • Log levels: Set the level of noisy loggers in application.properties, for example logging.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_ENDPOINT is https://ingest.<region>.signoz.cloud:443 with your region, and that OTEL_EXPORTER_OTLP_HEADERS has your ingestion key. Make sure that OTEL_LOGS_EXPORTER is not set to none.
  • Verify: Restart the application and send a request. The Failed to export warnings stop, and the logs appear in the Logs Explorer.

The agent does not start

  • Likely cause: the -javaagent flag 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 -javaagent flag 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_id only 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

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.

Is this page helpful

Last updated—November 26, 2026