Skip to content

Use Claude Code, Codex, VSCode, Pi, and OpenCode (and 6 other harnesses) for free (1.3B+ free tokens) from your terminal, app, IDE, or phone, and now from the browser with native browser sessions (multi-harness + multi-model) like OpenClaw (voice supported + ToS friendly)

Python

fix: default logs to logs/ and ignore rotations (issue 427)

Alishahryar1f389cf415ebe
diff --git a/.gitignore b/.gitignore
index 5400e2fd..e58febbb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,7 +7,9 @@ __pycache__
.venv
agent_workspace
.env
+/logs/
server.log
+/server.*.log
debug-*.log
.coverage
llama_cache
diff --git a/api/admin_config.py b/api/admin_config.py
index 349c6bbe..85f91333 100644
--- a/api/admin_config.py
+++ b/api/admin_config.py
@@ -418,7 +418,7 @@ FIELDS: tuple[ConfigFieldSpec, ...] = (
"Log File",
"runtime",
settings_attr="log_file",
- default="server.log",
+ default="logs/server.log",
restart_required=True,
),
ConfigFieldSpec(
diff --git a/config/logging_config.py b/config/logging_config.py
index 560b198b..1f09bb04 100644
--- a/config/logging_config.py
+++ b/config/logging_config.py
@@ -1,7 +1,7 @@
"""Loguru-based structured logging configuration.
-All logs are written to server.log as JSON lines for full traceability.
-Stdlib logging is intercepted and funneled to loguru.
+Structured logs are written as JSON lines to a configurable path (default
+``logs/server.log``). Stdlib logging is intercepted and funneled to loguru.
Context vars (request_id, node_id, chat_id) from contextualize() are
included at top level for easy grep/filter.
"""
@@ -123,8 +123,11 @@ def configure_logging(
# Remove default loguru handler (writes to stderr)
logger.remove()
+ log_path = Path(log_file)
+ log_path.parent.mkdir(parents=True, exist_ok=True)
+
# Truncate log file on fresh start for clean debugging
- Path(log_file).write_text("")
+ log_path.write_text("")
# Add file sink: JSON lines, DEBUG level, context vars at top level
logger.add(
diff --git a/config/settings.py b/config/settings.py
index aee458f5..9f7afe25 100644
--- a/config/settings.py
+++ b/config/settings.py
@@ -306,7 +306,7 @@ class Settings(BaseSettings):
# ==================== Server ====================
host: str = "0.0.0.0"
port: int = 8082
- log_file: str = "server.log"
+ log_file: str = "logs/server.log"
# Optional server API key to protect endpoints (Anthropic-style)
# Set via env `ANTHROPIC_AUTH_TOKEN`. When empty, no auth is required.
anthropic_auth_token: str = Field(
diff --git a/tests/config/test_logging_config.py b/tests/config/test_logging_config.py
index 9f54df03..9dfed204 100644
--- a/tests/config/test_logging_config.py
+++ b/tests/config/test_logging_config.py
@@ -9,6 +9,13 @@ from loguru import logger
from config.logging_config import configure_logging
+def test_configure_logging_creates_parent_directories(tmp_path) -> None:
+ """Nested log path: parent directories are created before truncating."""
+ log_file = tmp_path / "nested" / "dir" / "app.log"
+ configure_logging(str(log_file), force=True)
+ assert log_file.is_file()
+
+
def test_configure_logging_writes_json_to_file(tmp_path):
"""configure_logging writes JSON lines to the specified file."""
log_file = str(tmp_path / "test.log")