-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
Description
Background
The current java-tron logging system has three concrete problems affecting observability, startup clarity, and graceful shutdown:
- gRPC logs bypass Logback and go directly to stderr. grpc-java uses
java.util.logging(JUL) internally. While the project already includesjcl-over-slf4j, the JUL→SLF4J bridge is absent. As a result, gRPC diagnostic messages — connection resets, TLS handshake failures, etc. — never reachtron.log, forcing operators to monitor both stderr and log files simultaneously during RPC troubleshooting (see grpc-java#1577). - DB stats logging generates excessive INFO noise at startup.
DbStat.statProperty()logs at INFO level, flooding startup output and burying critical initialization messages. - Shutdown logs are incomplete on abnormal exits. After receiving SIGTERM,
TronLogShutdownHookwaits up to 60 seconds before closing. If the node hangs during this window, critical shutdown-phase logs may never be flushed.
Core Changes
- JUL→SLF4J bridge: Add
jul-to-slf4jas a dependency and callSLF4JBridgeHandler.install()at the earliest possible point during node startup, after resetting the default JUL handlers. This routes all gRPC JUL output into SLF4J/Logback for centralized collection.
java
// Remove default JUL handlers to prevent duplicate output
java.util.logging.LogManager.getLogManager().reset();
SLF4JBridgeHandler.install();groovy
// build.gradle
implementation 'org.slf4j:jul-to-slf4j:1.7.36'
- DB stats log level downgrade: Change
log.info(...)calls inDbStat.statProperty()and similar high-frequency periodic stat methods tolog.debug(...), reducing startup noise without losing diagnostic value. - Shutdown log completeness: Introduce a
volatile boolean shuttingDownflag inTronLogShutdownHook, shorten unnecessary wait intervals, and ensure critical log buffers are flushed as a first-priority step in the JVM shutdown hook.
Configuration Changes
- Add an explicit logger level entry for
io.grpcinlogback.xmlso operators can tune gRPC log verbosity independently. - DB stats loggers default to DEBUG; operators can promote them on demand.
No API / Protocol Changes
This change has no impact on external APIs or the network protocol.
Testing Strategy
- Verify that gRPC diagnostic logs (connection resets, TLS failures, etc.) appear in
tron.logand are no longer emitted to stderr. - Compare INFO-level log entry counts during node startup before and after — confirm a significant reduction in DB stats noise.
- Simulate an abnormal shutdown (send SIGTERM, then stall the process) and verify that critical shutdown-phase entries are complete and timely.
Performance Considerations
SLF4JBridgeHandlerintroduces marginal overhead for JUL log forwarding, but gRPC diagnostic logs are infrequent during normal operation — the impact is negligible.- Downgrading DB stats logs reduces log I/O volume with no runtime performance cost.
Scope of Impact
- Other: logging initialization, DB module stats log level, node shutdown lifecycle
Breaking Changes: None
Backward Compatibility: None
Alternatives Considered None
References
Reactions are currently unavailable