Skip to content

feat(node): update log level via admin API - #25281

Open
spalladino wants to merge 1 commit into
merge-train/spartan-v5from
spl/set-log-level-via-api
Open

feat(node): update log level via admin API#25281
spalladino wants to merge 1 commit into
merge-train/spartan-v5from
spl/set-log-level-via-api

Conversation

@spalladino

Copy link
Copy Markdown
Contributor

Allow changing the log level of a running node at runtime through the node admin API, instead of only via the LOG_LEVEL env var at startup.

Context

Diagnosing issues on a live node often requires more verbose logging, but until now the only way to change the log level was restarting the node with a different LOG_LEVEL — losing the state you were trying to observe.

Approach

  • Adds an optional logLevel key to AztecNodeAdminConfig, so it flows through the existing aztecAdmin_setConfig / aztecAdmin_getConfig methods with their auth and merge semantics. The value uses the same spec format as the LOG_LEVEL env var (e.g. debug;trace:sequencer,p2p) and is validated at the RPC boundary.
  • Pino child loggers bake in their level at creation and do not follow later changes to the parent, so @aztec/foundation/log now keeps a registry of all live child loggers (weakly held via WeakRef/FinalizationRegistry, since some paths create short-lived per-tx loggers). A new setLogLevel re-levels the root and every registered child per the new filters; loggers created afterwards pick up the new levels too. libp2p component loggers go through the same registry.
  • No transport changes needed: all transports are already registered at trace, so gating happens entirely at the logger.

The change only affects the node's own process — spawned prover agents and external binaries keep their configuration — and is not persisted: a restart reverts to the LOG_LEVEL env var.

API changes

AztecNodeAdmin.setConfig accepts an optional logLevel string and getConfig reports the current spec. @aztec/foundation/log exports new setLogLevel, getLogLevel, formatLogLevelSpec, and isValidLogLevelSpec functions.

Example:

curl -s http://node:8880/ -H 'x-api-key: ...' \
  -d '{"jsonrpc":"2.0","id":1,"method":"aztecAdmin_setConfig","params":[{"logLevel":"debug;trace:p2p"}]}'

Adds a logLevel key to the node admin config, settable at runtime via
aztecAdmin_setConfig using the LOG_LEVEL env var format (e.g.
"debug;trace:sequencer,p2p") and reported by aztecAdmin_getConfig.

Since pino child loggers do not follow their parent's level after
creation, foundation now keeps a weak registry of all live child
loggers (including libp2p ones) and exposes setLogLevel/getLogLevel to
update their levels in place. New loggers created after the change pick
up the updated levels as well. Only affects the node process; spawned
processes keep their own configuration, and a restart reverts to the
LOG_LEVEL env var.
@github-actions github-actions Bot added the port-to-next Forward-port this merged PR into next label Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

port-to-next Forward-port this merged PR into next

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant