openclaw - 💡(How to fix) Fix Bug: `logging.file` config ignored — bundled require("../config/config.js") fails at runtime [2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#59370Fetched 2026-04-08 02:24:37
View on GitHub
Comments
2
Participants
3
Timeline
4
Reactions
0
Author
Timeline (top)
commented ×2mentioned ×1subscribed ×1

The logging.file config option in openclaw.json is completely ignored. Logs are always written to the default /tmp/openclaw/openclaw-YYYY-MM-DD.log regardless of what logging.file is set to.

All other config options (models, channels, cron, etc.) load correctly — only logging is affected.

Error Message

$ node -e " const { createRequire } = require("module"); const req = createRequire("file:///.../openclaw/dist/logger-BCzP_yik.js"); req("../config/config.js"); " Error: MODULE_NOT_FOUND Cannot find module "../config/config.js"

Root Cause

In the bundled dist, the logger modules use require("../config/config.js") to load logging config:

// dist/logger-BCzP_yik.js (line 224-232)
const requireConfig$1 = resolveNodeRequireFromMeta(import.meta.url);

function readLoggingConfig() {
    const logging = ((requireConfig$1?.("../config/config.js"))?.loadConfig?.())?.logging;
    // ...
}

However, the Vite build outputs hashed filenames (e.g. dist/config-z_P7MACO.js), so ../config/config.js does not exist:

$ node -e "
  const { createRequire } = require(\"module\");
  const req = createRequire(\"file:///.../openclaw/dist/logger-BCzP_yik.js\");
  req(\"../config/config.js\");
"
Error: MODULE_NOT_FOUND Cannot find module "../config/config.js"

The optional chaining (?.) silently swallows the null return from resolveNodeRequireFromMeta when the require fails, so readLoggingConfig() returns undefined. Then resolveSettings() falls back:

file: cfg?.file ?? defaultRollingPathForToday()
// cfg is undefined → always uses /tmp/openclaw/

This appears to be a build/packaging issue — the config module exists but with a hashed filename that the require path does not account for.

Fix Action

Workaround

Use the default log path at /tmp/openclaw/. No config-based workaround exists since the config is never loaded.

Code Example

// dist/logger-BCzP_yik.js (line 224-232)
const requireConfig$1 = resolveNodeRequireFromMeta(import.meta.url);

function readLoggingConfig() {
    const logging = ((requireConfig$1?.("../config/config.js"))?.loadConfig?.())?.logging;
    // ...
}

---

$ node -e "
  const { createRequire } = require(\"module\");
  const req = createRequire(\"file:///.../openclaw/dist/logger-BCzP_yik.js\");
  req(\"../config/config.js\");
"
Error: MODULE_NOT_FOUND Cannot find module "../config/config.js"

---

file: cfg?.file ?? defaultRollingPathForToday()
// cfg is undefined → always uses /tmp/openclaw/

---

{ "logging": { "file": "/home/user/.openclaw/logs/gateway.log" } }
RAW_BUFFERClick to expand / collapse

Description

The logging.file config option in openclaw.json is completely ignored. Logs are always written to the default /tmp/openclaw/openclaw-YYYY-MM-DD.log regardless of what logging.file is set to.

All other config options (models, channels, cron, etc.) load correctly — only logging is affected.

Root Cause

In the bundled dist, the logger modules use require("../config/config.js") to load logging config:

// dist/logger-BCzP_yik.js (line 224-232)
const requireConfig$1 = resolveNodeRequireFromMeta(import.meta.url);

function readLoggingConfig() {
    const logging = ((requireConfig$1?.("../config/config.js"))?.loadConfig?.())?.logging;
    // ...
}

However, the Vite build outputs hashed filenames (e.g. dist/config-z_P7MACO.js), so ../config/config.js does not exist:

$ node -e "
  const { createRequire } = require(\"module\");
  const req = createRequire(\"file:///.../openclaw/dist/logger-BCzP_yik.js\");
  req(\"../config/config.js\");
"
Error: MODULE_NOT_FOUND Cannot find module "../config/config.js"

The optional chaining (?.) silently swallows the null return from resolveNodeRequireFromMeta when the require fails, so readLoggingConfig() returns undefined. Then resolveSettings() falls back:

file: cfg?.file ?? defaultRollingPathForToday()
// cfg is undefined → always uses /tmp/openclaw/

This appears to be a build/packaging issue — the config module exists but with a hashed filename that the require path does not account for.

Steps to Reproduce

  1. Set logging.file in ~/.openclaw/openclaw.json:
    { "logging": { "file": "/home/user/.openclaw/logs/gateway.log" } }
  2. Restart gateway: openclaw gateway restart
  3. Observe: logs go to /tmp/openclaw/, not the configured path
  4. Verify: ~/.openclaw/logs/gateway.log remains empty

Expected Behavior

Logs should be written to the path specified in logging.file.

Actual Behavior

Logs always go to /tmp/openclaw/openclaw-YYYY-MM-DD.log. The logging.file config is never read.

Environment

  • OpenClaw: 2026.4.1 (da64a97)
  • OS: WSL2 (Linux 6.6.87.2-microsoft-standard-WSL2, x64)
  • Node: v22.22.0
  • Install method: npm global (npm i -g openclaw)
  • Config location: ~/.openclaw/openclaw.json

Workaround

Use the default log path at /tmp/openclaw/. No config-based workaround exists since the config is never loaded.

Notes

  • resolveSettings() also appears in logger-BGSZ8m40.js with the same issue — both logger bundles reference ../config/config.js which does not exist in the hashed dist output.
  • The same requireConfig pattern works elsewhere in the codebase (e.g. subsystem-*.js) but those modules may resolve through a different code path that does not depend on readLoggingConfig().

extent analysis

TL;DR

The issue can be fixed by updating the require path in the logger modules to account for the hashed filenames in the Vite build output.

Guidance

  • Verify that the config.js file is being generated with a hashed filename in the dist directory.
  • Update the require path in the logger modules to use a dynamic path that can resolve to the hashed config.js filename.
  • Consider using a consistent naming convention for the config.js file to avoid issues with hashed filenames.
  • Review the resolveNodeRequireFromMeta function to ensure it can handle hashed filenames correctly.

Example

// Update the require path to use a dynamic path
const configPath = '../config/config-' + hash + '.js';
const logging = ((requireConfig$1?.(configPath))?.loadConfig?.())?.logging;

Note: The hash variable should be replaced with the actual hash value used in the Vite build output.

Notes

  • The issue appears to be specific to the logger modules and may not affect other parts of the codebase.
  • The resolveSettings() function may need to be updated to handle the case where the logging.file config is not loaded correctly.

Recommendation

Apply a workaround by updating the require path in the logger modules to account for the hashed filenames, as this is a build/packaging issue that requires a code change to fix.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Bug: `logging.file` config ignored — bundled require("../config/config.js") fails at runtime [2 comments, 3 participants]