-
Notifications
You must be signed in to change notification settings - Fork 5
feat(log): bridge JUL to SLF4J and improve shutdown log reliability #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f0a8f0f
b0e4b0a
6b1c568
29da801
945c647
30f3c49
e2881ed
f0bcb34
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,14 @@ | |||||||||
|
|
||||||||||
| <configuration> | ||||||||||
|
|
||||||||||
| <!-- Propagate logback level changes back to JUL, eliminating the 60x overhead | ||||||||||
|
halibobo1205 marked this conversation as resolved.
|
||||||||||
| for disabled log statements when using the jul-to-slf4j bridge. | ||||||||||
| resetJUL=true clears any explicit JUL logger levels so that the levels | ||||||||||
| declared below are the effective ones. --> | ||||||||||
| <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator"> | ||||||||||
| <resetJUL>true</resetJUL> | ||||||||||
| </contextListener> | ||||||||||
|
|
||||||||||
| <!-- Be sure to flush latest logs on exit --> | ||||||||||
| <shutdownHook class="org.tron.core.config.TronLogShutdownHook"/> | ||||||||||
| <conversionRule conversionWord="m" | ||||||||||
|
|
@@ -61,19 +69,17 @@ | |||||||||
| <!-- (the smaller value -> flush occurs often) --> | ||||||||||
| <queueSize>100</queueSize> | ||||||||||
| <includeCallerData>true</includeCallerData> | ||||||||||
| <!-- Allow up to 5 s to drain the queue on shutdown before giving up --> | ||||||||||
| <maxFlushTime>5000</maxFlushTime> | ||||||||||
|
Comment on lines
+72
to
+73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: The async appender is configured to abandon flushing after only 5 seconds, which can still drop queued shutdown logs under slow I/O or burst logging even though shutdown now waits much longer. Increase the flush window to align with the shutdown wait budget so buffered events are not prematurely discarded. [logic error] Severity Level: Major
|
||||||||||
| <!-- Allow up to 5 s to drain the queue on shutdown before giving up --> | |
| <maxFlushTime>5000</maxFlushTime> | |
| <!-- Allow up to 120 s to drain the queue on shutdown before giving up --> | |
| <maxFlushTime>120000</maxFlushTime> |
Steps of Reproduction ✅
1. Start any java-tron node (e.g., FullNode) so Logback loads
`framework/src/main/resources/logback.xml`, which registers `TronLogShutdownHook` via
`<shutdownHook class="org.tron.core.config.TronLogShutdownHook"/>` at lines 5–6 and routes
root logging through the async appender defined at lines 56–66.
2. Drive the node under load so components like the HTTP API
(`framework/src/main/java/org/tron/core/services/http/FullNodeHttpApiService.java:18–23`,
annotated with `@Slf4j(topic = "API")`) emit many INFO/DEBUG logs, filling the async
appender queue (`queueSize=100` at `logback.xml:62`).
3. Initiate process shutdown with SIGTERM/CTRL-C so Logback's shutdown hook runs
`TronLogShutdownHook.run()`
(`framework/src/main/java/org/tron/core/config/TronLogShutdownHook.java:34–49`), which
waits up to `MAX_WAIT_MS = 3 * 60 * 1000` (lines 18–23) for a graceful shutdown and then
calls `super.stop()` to stop the Logback context.
4. At context stop, the async appender (`logback.xml:56–65`) flushes its queue but is
limited by `<maxFlushTime>5000</maxFlushTime>` (5 s); under slow I/O or a large queued
burst, events still in the queue after 5 s are dropped, so the last seconds of logs before
exit are missing from `./logs/tron.log` even though the shutdown hook allowed up to 180 s
for shutdown.Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** framework/src/main/resources/logback.xml
**Line:** 64:65
**Comment:**
*Logic Error: The async appender is configured to abandon flushing after only 5 seconds, which can still drop queued shutdown logs under slow I/O or burst logging even though shutdown now waits much longer. Increase the flush window to align with the shutdown wait budget so buffered events are not prematurely discarded.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Uh oh!
There was an error while loading. Please reload this page.