#19867: Logging: Add configurable log dir
docs
channel: signal
app: macos
gateway
size: S
Cluster:
Hooks and UI Fixes
- Adds a new logging.dir config field
- Adds unit tests for the default case (`logging.dir` unspecified) and the new case (`logging.dir` set)
- Update all associated logging path discussion in the docs
## Summary
This PR allows users to set a configurable logging directory while preserving the default logfile rotation behavior.
- Problem: Logfiles only rotate automatically with the default logging configuration. Users can hardcode a logfile name, but this file is no longer rotated.
- Why it matters: Automatic logfile rotation is important for keeping disk usage for logfiles under control. It doesn't guarantee unbounded growth in logfile disk utilization, but it can help reclaim space after disk usage spikes.
- What changed: Added a `dir` field to the logging config object, updated how the logging file dir is computed, and updated docs.
- What did NOT change (scope boundary): Everything else is as-is, this is just changing what logging directory the config resolves to
## Change Type (select all)
- [ ] Bug fix
- [ x] Feature
- [ ] Refactor
- [ ] Docs
- [ ] Security hardening
- [ ] Chore/infra
## Scope (select all touched areas)
- [x ] Gateway / orchestration
- [ ] Skills / tool execution
- [ ] Auth / tokens
- [ ] Memory / storage
- [ ] Integrations
- [ ] API / contracts
- [ ] UI / DX
- [ ] CI/CD / infra
## Linked Issue/PR
None
## User-visible / Behavior Changes
No behavior change in the default config. If the user specifies `logging.dir`, the standard rotating logfile will be written to that directory, instead.
## Security Impact (required)
- New permissions/capabilities? No
- Secrets/tokens handling changed? No
- New/changed network calls? No
- Command/tool execution surface changed? No
- Data access scope changed? No
- If any `Yes`, explain risk + mitigation: n/a
## Repro + Verification
n/a
Attach at least one:
```
% pnpm test src/logging/logger.test.ts
> openclaw@2026.2.18 test /Users/pdav/source/paudav_openclaw
> node scripts/test-parallel.mjs src/logging/logger.test.ts
RUN v4.0.18 /Users/pdav/source/paudav_openclaw
✓ src/logging/logger.test.ts (2 tests) 5ms
✓ logger directory resolution (2)
✓ writes to DEFAULT_LOG_DIR when dir is not specified 4ms
✓ writes to configured directory when dir is specified 0ms
Test Files 1 passed (1)
Tests 2 passed (2)
Start at 23:52:24
Duration 170ms (transform 62ms, setup 73ms, import 2ms, tests 5ms, environment 0ms)
%
```
## Human Verification (required)
Unit tests
## Compatibility / Migration
- Backward compatible? Yes
- Config/env changes? Yes, new config option exposed
- Migration needed? No
## Failure Recovery (if this breaks)
- How to disable/revert this change quickly: Just revert it
- Files/config to restore: Ideally, then entire commit, but at a minimum `src/logging/logger.ts`, `src/config/types.base.ts`, and `src/logging/logger.test.ts`
- Known bad symptoms reviewers should watch for: none
## Risks and Mitigations
None
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Added configurable `logging.dir` field to control the directory where rolling daily log files are written, while preserving automatic log rotation. The implementation correctly maintains backward compatibility (defaults to `/tmp/openclaw/`) and ensures `logging.file` takes precedence over `logging.dir` when both are set. Documentation has been comprehensively updated across all affected files to explain the new field and its interaction with `logging.file`.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The implementation is straightforward, well-tested, and maintains backward compatibility. The precedence logic (`file` over `dir`) is correctly implemented, and all documentation has been comprehensively updated. The tests properly mock filesystem operations, addressing the existing review comment.
- No files require special attention
<sub>Last reviewed commit: cb16ec5</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#11281: fix(logging): prevent subsystem loggers from bypassing file log lev...
by janckerchen · 2026-02-07
76.0%
#22478: fix(diagnostics-otel): wire OTLP exporter to emit traffic to config...
by LuffySama-Dev · 2026-02-21
72.0%
#18179: CLI: add sessions --json-debug diagnostics
by p6l-richard · 2026-02-16
71.4%
#11305: fix(logging): remove redundant subsystem prefix from log output
by janckerchen · 2026-02-07
71.3%
#23669: refactor(logging): migrate node-host and tailscale console calls to...
by kevinWangSheng · 2026-02-22
71.2%
#20877: Store config backups in their own directory
by pierreeurope · 2026-02-19
71.1%
#17896: fix(config): warn instead of silently swallowing chmod failure on c...
by PlayerGhost · 2026-02-16
69.7%
#11602: fix(config): skip stale legacy config files when openclaw.json exists
by akoscz · 2026-02-08
69.5%
#15253: Adding structured log content
by emailhxn · 2026-02-13
69.3%
#17916: [ fix ] : correct config directory path during onboarding
by Dijo-404 · 2026-02-16
69.2%