Skip to content

feat(log): bridge JUL to SLF4J and improve shutdown log reliability#122

Closed
halibobo1205 wants to merge 8 commits intodevelopfrom
feat/log_grpc
Closed

feat(log): bridge JUL to SLF4J and improve shutdown log reliability#122
halibobo1205 wants to merge 8 commits intodevelopfrom
feat/log_grpc

Conversation

@halibobo1205
Copy link
Copy Markdown
Owner

@halibobo1205 halibobo1205 commented Apr 4, 2026

Summary

Six operator-facing logging improvements:

  1. gRPC logs land in tron.log. Install SLF4JBridgeHandler (jul-to-slf4j) at the earliest startup point so grpc-java's JUL output is routed through Logback instead of bypassing it to stderr.
  2. DB stats no longer flood startup at INFO. DbStat.statProperty() moved to DEBUG — critical init messages are no longer buried.
  3. Shutdown logs are complete. TronLogShutdownHook refactored: constants named, max wait raised from 60 s to 180 s to give the node's executor pools realistic headroom to drain (each pool can take up to 120 s via ExecutorServiceManager.shutdownAndAwaitTermination).
  4. Slow signature verifications are visible. TransactionCapsule.logSlowSigVerify(...) emits INFO for any single verify > 50 ms.
  5. LevelDB open stalls are no longer silent. LevelDbDataSourceImpl wraps the JNI-blocking factory.open(...) in a watchdog: WARN after 60 s with a remediation hint pointing at Toolkit.jar db archive.
  6. Invalid --log-config fails fast. LogService.load(...) throws TronError(ErrCode.LOG_LOAD) on an unreadable --log-config path. Previously, it silently fell back to the classpath default, misleading operators into thinking their custom config was active.

Impact

  • Mainnet / Nile / operators: grpc TLS/handshake/connection-reset diagnostics now land in tron.log; startup no longer dumps DB stats at INFO; a stuck LevelDB factory.open emits one actionable WARN every 30 s pointing at Toolkit.jar db archive.
  • CI output: test root logger moved from DEBUG to INFO to reduce CI log volume so failures are easier to locate after a red build. Tests that genuinely rely on DEBUG opt in per-logger in logback-test.xml.

Release scope

Logging-only change: no API, no RPC, no network, no DB format change.

@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 4, 2026

CodeAnt AI is reviewing your PR.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@codeant-ai codeant-ai Bot added the size:M This PR changes 30-99 lines, ignoring generated files label Apr 4, 2026
Comment thread framework/src/main/java/org/tron/core/config/TronLogShutdownHook.java Outdated
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 4, 2026

CodeAnt AI finished reviewing your PR.

@halibobo1205
Copy link
Copy Markdown
Owner Author

@CodeAnt-AI: review

@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 5, 2026

CodeAnt AI is running the review.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai Bot added size:M This PR changes 30-99 lines, ignoring generated files and removed size:M This PR changes 30-99 lines, ignoring generated files labels Apr 5, 2026
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 5, 2026

Sequence Diagram

This PR routes Java runtime and gRPC JUL logs into the standard SLF4J/Logback pipeline and extends the log shutdown hook to wait longer and flush the async queue, reducing lost logs during shutdown.

sequenceDiagram
    participant Node
    participant JulLogger
    participant Slf4jBridge
    participant LoggingSystem
    participant LogFile
    participant ShutdownHook

    Node->>JulLogger: Emit runtime diagnostic log
    JulLogger->>Slf4jBridge: Forward JUL log record
    Slf4jBridge->>LoggingSystem: Route as SLF4J event
    LoggingSystem->>LogFile: Append to application log

    Node->>ShutdownHook: JVM shutdown starts
    ShutdownHook->>Node: Wait for graceful shutdown up to 120 s
    ShutdownHook->>LoggingSystem: Stop logging and flush queue up to 5 s
    LoggingSystem->>LogFile: Persist remaining log events
Loading

Generated by CodeAnt AI

Comment thread framework/src/main/java/org/tron/core/config/TronLogShutdownHook.java Outdated
Comment thread common/src/main/java/org/tron/common/parameter/CommonParameter.java Outdated
Comment thread common/src/main/java/org/tron/common/parameter/CommonParameter.java Outdated
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 5, 2026

CodeAnt AI finished running the review.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 7, 2026

CodeAnt AI is running Incremental review


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai Bot added size:M This PR changes 30-99 lines, ignoring generated files and removed size:M This PR changes 30-99 lines, ignoring generated files labels Apr 7, 2026
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 7, 2026

CodeAnt AI Incremental review completed.

@halibobo1205
Copy link
Copy Markdown
Owner Author

@CodeAnt-AI: review

@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 7, 2026

CodeAnt AI is running the review.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai Bot added size:M This PR changes 30-99 lines, ignoring generated files and removed size:M This PR changes 30-99 lines, ignoring generated files labels Apr 7, 2026
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 7, 2026

Sequence Diagram

This PR routes gRPC Java util logging into the existing SLF4J Logback pipeline and extends the shutdown hook to wait longer and flush the async log queue, reducing lost logs during runtime and shutdown.

sequenceDiagram
    participant Node
    participant CommonParameter
    participant gRPC
    participant LoggingBridge
    participant Logback
    participant LogFile
    participant ShutdownHook

    Node->>CommonParameter: Load configuration (static initializer)
    CommonParameter->>LoggingBridge: Install JUL to SLF4J and set gRPC log level
    gRPC->>LoggingBridge: Emit diagnostic log
    LoggingBridge->>Logback: Forward log to async appender
    Logback->>LogFile: Append application log entry

    Node->>ShutdownHook: Trigger TronLogShutdownHook on shutdown
    ShutdownHook->>ShutdownHook: Wait up to max time for graceful shutdown
    ShutdownHook->>Logback: Request async queue flush with timeout
    Logback->>LogFile: Persist remaining log entries before stop
Loading

Generated by CodeAnt AI

@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 7, 2026

CodeAnt AI finished running the review.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 8, 2026

CodeAnt AI is running Incremental review


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai Bot added size:M This PR changes 30-99 lines, ignoring generated files and removed size:M This PR changes 30-99 lines, ignoring generated files labels Apr 8, 2026
@halibobo1205
Copy link
Copy Markdown
Owner Author

@CodeAnt-AI: review

@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 8, 2026

CodeAnt AI Incremental review completed.

@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 8, 2026

CodeAnt AI is running the review.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 21, 2026

CodeAnt AI finished running the review.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

1 similar comment
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 21, 2026

CodeAnt AI finished running the review.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 21, 2026

CodeAnt AI is running the review.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai Bot added size:L This PR changes 100-499 lines, ignoring generated files and removed size:L This PR changes 100-499 lines, ignoring generated files labels Apr 21, 2026
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 21, 2026

Sequence Diagram

This PR routes Java Util Logging (including gRPC and Netty) into the main Logback configuration via a JUL to SLF4J bridge and extends the shutdown hook to wait longer and flush the async appender, reducing lost logs during shutdown.

sequenceDiagram
    participant App
    participant JULLibraries
    participant SLF4JBridge
    participant Logback
    participant ShutdownHook

    App->>App: Initialize common parameters
    App->>SLF4JBridge: Install JUL to SLF4J bridge
    JULLibraries->>SLF4JBridge: Emit JUL log events
    SLF4JBridge->>Logback: Forward events to configured appenders

    App->>ShutdownHook: Trigger node shutdown
    ShutdownHook->>ShutdownHook: Wait for graceful shutdown up to max time
    ShutdownHook->>Logback: Stop context and flush async appender queue
Loading

Generated by CodeAnt AI

@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 21, 2026

CodeAnt AI finished running the review.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 22, 2026

CodeAnt AI is running Incremental review


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai Bot added size:L This PR changes 100-499 lines, ignoring generated files and removed size:L This PR changes 100-499 lines, ignoring generated files labels Apr 22, 2026
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 22, 2026

CodeAnt AI Incremental review completed.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 937b6cf5f4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f881fd2692

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread framework/src/test/java/org/tron/core/capsule/TransactionCapsuleTest.java Outdated
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 23, 2026

CodeAnt AI is running Incremental review


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai Bot added size:XL This PR changes 500-999 lines, ignoring generated files and removed size:L This PR changes 100-499 lines, ignoring generated files labels Apr 23, 2026
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented Apr 23, 2026

CodeAnt AI Incremental review completed.

### What Changed
- gRPC now appear in the application log instead of going only to standard error.
- Database size stats are no longer printed at info level during startup, which reduces log noise.
- Shutdown now waits longer before stopping the log system, giving pending messages more time to flush.
- Async appender now allows up to 5 seconds to drain its queue on shutdown.
- Interrupted shutdowns now show a clearer log message.
- Test log config is INFO level.

### Impact
`✅ Fewer missed gRPC error logs`
`✅ Cleaner startup output`
`✅ Fewer lost shutdown logs`
`✅ Fewer test logs`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL This PR changes 500-999 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants