| [ Web Proxy ] |
| Viewing: https://adk.dev/integrations/../../live/../../../../../../../../../../../../observability/logging/ | [Back] [Original] |
[logo]
Agent Development Kit (ADK) provides flexible and powerful logging capabilities to monitor agent behavior and debug issues effectively.
ADK's approach to logging is to provide detailed diagnostic information without being overly verbose by default. It is designed to be configured by the application developer, allowing you to tailor the log output to your specific needs, whether in a development or production environment.
logging module, Go's log package).ADK emits logs using standard library facilities and structured GenAI events via OpenTelemetry.
Structured GenAI logs emitted via OpenTelemetry follow the Semantic Conventions for GenAI.
By default prompt content is elided in logs for security. You can enable prompt
logging using environment variables or programmatic configuration. See
Capture prompt content for adk web, and
Capture prompt content programmatically
for setup in code.
The following table describes what is logged at different levels in Python when using the standard logger:
| Level | Description | Type of Information Logged |
|---|---|---|
DEBUG |
Crucial for debugging. The most verbose level for fine-grained diagnostic information. |
|
INFO |
General information about the agent's lifecycle. |
|
WARNING |
Indicates a potential issue or deprecated feature use. The agent continues to function, but attention may be required. |
|
ERROR |
A serious error that prevented an operation from completing. |
|
Note
It is recommended to use INFO or WARNING in production environments.
Only enable DEBUG when actively troubleshooting an issue, as DEBUG logs
can be very verbose and may contain sensitive information.
When running agents using the ADK's adk web, adk api_server, adk deploy
cloud_run and adk deploy gke commands, you can control the log verbosity or
destination.
To start the web server with DEBUG level logging, run:
The available log levels for the --log_level option are: DEBUG, INFO
(default), WARNING, ERROR, CRITICAL.
By default a prompt content is elided in logs for security. You can enable prompt logging using the environment variable:
The available values for this variable are: NO_CONTENT, EVENT_ONLY,
SPAN_ONLY, and SPAN_AND_EVENT. A boolean true or 1 means EVENT_ONLY,
which records content on the emitted log events; any value outside these four
falls back to NO_CONTENT. To record content on the inference span, SPAN_ONLY
and SPAN_AND_EVENT also require
OTEL_SEMCONV_STABILITY_OPT_IN=gen_ai_latest_experimental.
Warning
The OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT setting logs the
full content of user prompts and agent responses. This is useful for
debugging but may capture sensitive data or PII. In production, set this to
false or ensure you have appropriate data handling policies in place.
To export logs to an OTLP-compatible backend, set the standard OTel environment variables:
export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT="http://your-collector:4318/v1/logs"
adk web path/to/your/agents_dir
Note
You can also set the general OTEL_EXPORTER_OTLP_ENDPOINT environment
variable if you would like to send metrics and traces to the same endpoint
in addition to logs.
You can enable GCP export using the --otel_to_cloud flag:
Programmatic setup configures the underlying logging framework and OpenTelemetry exporters from your own code, for system-level diagnostics and production observability. ADK uses the following logging facilities:
logging module and OpenTelemetry for
structured GenAI logs.google.golang.org/adk/v2/telemetry package for
OpenTelemetry configuration, and the standard log package for general
events, which it writes to stderr by default.You can set the logging level for your ADK agent using standard logging controls, as follows:
To enable detailed logging, including DEBUG level messages, add the following
to the top of your script:
General events (such as server startup or HTTP requests) are logged using the standard Go log package and written to stderr by default.
ADK uses standard JVM logging facilities (defaulting to Flogger). Configure your JVM logger backend, such as java.util.logging or SLF4J, to adjust log verbosity.
You can enable full prompt logging programmatically by setting an environment variable:
To scope content capture to a single run instead of the whole process, set
RunConfig.telemetry rather than the environment variable:
You can enable full prompt logging when initializing telemetry by exporting OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true:
package main
import (
"context"
"os"
"google.golang.org/adk/v2/telemetry"
)
func main() {
ctx := context.Background()
// Enable GenAI message content capture via the OpenTelemetry environment variable
os.Setenv("OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT", "true")
tp, err := telemetry.New(ctx)
if err != nil {
// handle error
}
defer tp.Shutdown(ctx)
tp.SetGlobalOtelProviders()
}
To export logs to an OpenTelemetry Collector (or an OTLP-compatible backend) programmatically:
from google.adk.telemetry.setup import maybe_set_otel_providers
import os
os.environ["OTEL_EXPORTER_OTLP_LOGS_ENDPOINT"] = "http://your-collector:4318/v1/logs"
os.environ["OTEL_SERVICE_NAME"] = "your-adk-agent"
os.environ["OTEL_RESOURCE_ATTRIBUTES"] = "key1=value1,key2=value2"
maybe_set_otel_providers()
To export logs to an OTLP-compatible backend, configure the standard
OpenTelemetry environment variables, such as OTEL_EXPORTER_OTLP_ENDPOINT
or OTEL_EXPORTER_OTLP_LOGS_ENDPOINT. The ADK telemetry package uses these
settings automatically when initialized.
ADK Kotlin's OpenTelemetry integration emits traces only it registers no
LoggerProvider, so there is no OTLP log export. Application logs go to your JVM
logging backend. To configure trace export, see the Traces
documentation.
To export logs to Google Cloud Logging programmatically, use the OpenTelemetry Google Cloud exporter. Here is an example in Python:
from google.adk.telemetry.google_cloud import get_gcp_exporters
from google.adk.telemetry.setup import maybe_set_otel_providers
import os
gcp_exporters = get_gcp_exporters(
enable_cloud_logging = True,
)
os.environ["OTEL_SERVICE_NAME"] = "your-adk-agent"
os.environ["OTEL_RESOURCE_ATTRIBUTES"] = "key1=value1,key2=value2"
maybe_set_otel_providers([gcp_exporters])
To export logs to Google Cloud Logging, use the WithOtelToCloud option:
package main
import (
"context"
"google.golang.org/adk/v2/telemetry"
)
func main() {
ctx := context.Background()
tp, err := telemetry.New(ctx,
telemetry.WithOtelToCloud(true),
)
if err != nil {
// handle error
}
defer tp.Shutdown(ctx)
tp.SetGlobalOtelProviders()
}
If using the Go launcher, you can also enable GCP export via the CLI flag:
ADK Kotlin emits no OpenTelemetry log records, so there is nothing for Cloud Logging
to receive; application logs go to your JVM logging backend. ADK Kotlin traces can
be sent to Google Cloud by pointing a standard OTLP exporter at telemetry.googleapis.com
see OTLP with Google Cloud
for the required credentials, quota project and roles/telemetry.writer grant.
ADK provides built-in plugins that capture agent activity, including user
messages, model requests and responses, tool calls, and (with
DebugLoggingPlugin) session state. These plugins require no changes to your
agent logic.
LoggingPlugin¶To print structured activity logs to the console during execution, attach
LoggingPlugin to your App:
package main
import (
"context"
"log"
"os"
"google.golang.org/adk/v2/agent"
"google.golang.org/adk/v2/cmd/launcher"
"google.golang.org/adk/v2/cmd/launcher/full"
"google.golang.org/adk/v2/plugin"
"google.golang.org/adk/v2/plugin/loggingplugin"
"google.golang.org/adk/v2/runner"
)
func main() {
ctx := context.Background()
logPlugin := loggingplugin.MustNew("logging_plugin")
config := &launcher.Config{
AgentLoader: agent.NewSingleLoader(rootAgent),
PluginConfig: runner.PluginConfig{
Plugins: []*plugin.Plugin{logPlugin},
},
}
l := full.NewLauncher()
if err := l.Execute(ctx, config, os.Args[1:]); err != nil {
log.Fatalf("run failed: %v", err)
}
}
DebugLoggingPlugin¶To record complete interaction data as human-readable YAML appended to
adk_debug.yaml rather than truncated console output, use
DebugLoggingPlugin:
Warning
The output file holds raw prompts, tool arguments, and session state.
Although ADK automatically redacts credentials and temp:-scoped state
keys in Python, treat the output file as sensitive.
2025-07-08 11:22:33,456 - DEBUG - google_adk.google.adk.models.google_llm - LLM Request: contents { ... }
| Log Segment | Format Specifier | Meaning |
|---|---|---|
2025-07-08 11:22:33,456 |
%(asctime)s |
Timestamp |
DEBUG |
%(levelname)s |
Severity level |
google_adk.google.adk.models.google_llm |
%(name)s |
Logger name (the module that produced the log) |
LLM Request: contents { ... } |
%(message)s |
The actual log message |
By reading the logger name, you can immediately pinpoint the source of the log
and understand its context within the agent's architecture.
ADK loggers are named google_adk. followed by the module's fully-qualified
name, so every ADK logger is a child of the google_adk logger. Configure them
as a group with logging.getLogger("google_adk").
After enabling DEBUG logging (see Logging level above), run
your agent and look for messages from the
google_adk.google.adk.models.google_llm logger.
The output shows the full LLM request and response:
2025-07-10 15:26:13,778 - DEBUG - google_adk.google.adk.models.google_llm -
LLM Request:
-----------------------------------------------------------
System Instruction:
You roll dice and answer questions about the outcome of the dice rolls.
...
-----------------------------------------------------------
Contents:
{"parts":[{"text":"Roll a 6 sided dice"}],"role":"user"}
{"parts":[{"function_call":{"args":{"sides":6},"name":"roll_die"}}],"role":"model"}
{"parts":[{"function_response":{"name":"roll_die","response":{"result":2}}}],"role":"user"}
-----------------------------------------------------------
Functions:
roll_die: {'sides': {'type': <Type.INTEGER: 'INTEGER'>}}
check_prime: {'nums': {'items': {'type': <Type.INTEGER: 'INTEGER'>}, 'type': <Type.ARRAY: 'ARRAY'>}}
-----------------------------------------------------------
2025-07-10 15:26:14,309 - INFO - google_adk.google.adk.models.google_llm -
LLM Response:
-----------------------------------------------------------
Text:
I have rolled a 6 sided die, and the result is 2.
...
From this output you can verify:
user and model turns) accurate?| Web Proxy Viewer | New URL | Original Page |