You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Corda NodeDriver V3日志问询:可否同时输出至控制台及其他配置?

NodeDriver V3+ Logging: Console Output & Additional Configs

Great question! Let's break this down clearly:

Can I still send logs to the console alongside files?

Absolutely! The shift to per-node file logs in V3 doesn't block you from also outputting logs to the console. The simplest approach is adjusting your project's underlying logging framework configuration—NodeDriver uses SLF4J under the hood, usually paired with Logback.

For example, in your logback.xml file, set up both a console and file appender for Corda's driver/logger namespaces:

<configuration>
    <!-- Console appender for real-time output -->
    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>

    <!-- File appender to match NodeDriver's default persistent logging -->
    <appender name="FILE" class="ch.qos.logback.core.FileAppender">
        <file>${corda.driver.log.dir}/node-logs.log</file>
        <encoder>
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>

    <!-- Attach both appenders to Corda driver logs -->
    <logger name="net.corda.node.driver" level="INFO">
        <appender-ref ref="CONSOLE"/>
        <appender-ref ref="FILE"/>
    </logger>
</configuration>

If you want quick, programmatic tweaks in your test code, you can also enable extra logging and set verbosity when initializing the driver to surface more output to the console:

val driver = NodeDriver.driver(
    driverDirectory = Paths.get("my-custom-log-folder"),
    loggingLevel = LoggingLevel.INFO,
    extraLogging = true
) {
    // Define your node setup here
}

Additional NodeDriver Logging Configuration Options

Beyond console output, here are useful tweaks to tailor your logging setup:

  • Custom Log Directory: Use the driverDirectory parameter to specify where all node log files are stored. Each node gets its own subfolder here, making it easy to isolate logs per node.
  • Adjust Verbosity: Set loggingLevel to control detail—use LoggingLevel.DEBUG for deep debugging, LoggingLevel.WARN to only see critical issues, or LoggingLevel.TRACE for extremely granular logs (use sparingly!).
  • Extra Debug Context: Enable extraLogging = true to get additional logs about driver operations, like node startup/shutdown sequences, RPC connection status, and transaction flow progress.
  • Per-Node Log Tweaks: When starting individual nodes via the driver, pass a custom NodeConfiguration to override logging settings for that specific node (e.g., a different log level or file path).
  • Disable File Logging: If you don't need persistent file logs (not recommended for long-running tests), modify your logging framework config to remove the file appender entirely.
  • Custom Log Formats: Use your logging framework's pattern settings to customize log entry structure—add timestamps, thread IDs, logger names, or custom markers to make logs easier to parse.

内容的提问来源于stack exchange,提问作者Matthieu Merlyn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 11:34:24