Skip to content

Allow configuring the SQLite log-database trace level (default_filter() hardcodes TRACE) #43378

Open

Description

@sunquanh

Summary

The SQLite log database (logs_2.sqlite, used by the desktop app / codex app-server) is written at TRACE level by default, with no way to lower or disable it. RUST_LOG only affects stderr output — it does not influence what gets persisted to the SQLite log DB.

Environment

  • codex-cli 0.153.4 (latest release as of 2026-09-04; issue also reproduced on current main)
  • Windows 11, ARM64
  • Desktop app usage with local codex app-server

Observation

While monitoring C:\Users\User\.codex\logs_2.sqlite for 60 seconds:

  • ~329 records written per minute (~5.5/s)
  • ~74% are TRACE events, dominated by codex_app_server::outgoing_message (~241/min) plus websocket remote_control (~70/min)
  • DB holds ~21 MB (self-cleanup keeps row count bounded around ~30k, so size does not grow unbounded)

The volume is small in absolute terms, but for users who do not need full TRACE history, this is continuous unnecessary write activity with no way to opt out.

Root cause

The filter for the SQLite log layer is hardcoded in codex-rs/state/src/log_db.rs:

pub fn default_filter() -> Targets {
    Targets::new()
        .with_default(LevelFilter::TRACE)   // hardcoded default for the log DB
        .with_target("h2", LevelFilter::WARN)
        .with_target("hyper_util", LevelFilter::WARN)
        .with_target("log", LevelFilter::OFF)
        // ...
}

This filter is applied to the LogDbLayer in:

  • codex-rs/app-server/src/lib.rs (~line 690): .with_filter(log_db::default_filter())
  • codex-rs/tui/src/startup_orchestration.rs (~line 587)

Unlike the stderr subscriber, this layer does not read RUST_LOG or any config value.

Feature request

Add a way to configure the SQLite log-DB level, for example:

  1. A config option (e.g. log_db_level / trace_file_level in config.toml), or
  2. A CLI flag (e.g. codex app-server --log-db-level info), or
  3. Make default_filter() derive from the configured/RUST_LOG-style filter instead of hardcoding TRACE.

I would expect sensible defaults to remain TRACE for development, with users able to opt down to INFO/DEBUG or disable persistence entirely.

Activity

  1. added
    enhancement
    app
    config
    on Sep 7, 2026
  2. piotrkowski commented on Nov 4, 2026

    @piotrkowski

    Adding Linux data from a TUI session (codex-cli 0.164.0, codex --yolo), in case it helps prioritise this.

    Environment: Linux 7.2, btrfs (compress=zstd:1,noatime) on LUKS2/dm-crypt, consumer DRAM-less NVMe (~600 TBW rating).

    What logs_2.sqlite contained (61 h window, 2026-11-01 23:57 → 2026-11-04 13:07, including idle time and suspend):

    rows inserted (by id) 306,441 (≈1.4 inserts/s averaged over the whole window)
    rows retained 25,139 (pruning keeps the table bounded, as in the original report)
    lifetime id 50,818,581
    avg estimated_bytes 1.2 KB
    DB / WAL size 95 MB / 20 MB

    Level split of retained rows: TRACE 37.9 %, DEBUG 30.5 %, INFO 31.1 %, WARN 0.5 %. Top targets:

    target level rows
    codex_app_server::outgoing_message TRACE 3,882
    codex_core::stream_events_utils DEBUG 3,731
    feedback_tags INFO 2,834
    codex_tui::markdown_stream TRACE 2,470
    codex_core::session::world_state TRACE 1,480

    So ~68 % of what is persisted is TRACE/DEBUG that, as far as I can tell, is only useful for feedback uploads.

    Why it matters more on some filesystems: on copy-on-write filesystems every small committed transaction also rewrites metadata, so a steady trickle of tiny inserts costs far more device writes than its logical size (Mohan et al., arXiv:1707.08514, measured ~33× write amplification on btrfs for 4 KB random overwrites + fsync vs ~2–4× on xfs/ext4).

    Workaround I used (unofficial, documented here only so others can measure the difference):

    -- with Codex stopped; keep a backup of logs_2.sqlite
    CREATE TRIGGER block_log_inserts BEFORE INSERT ON logs BEGIN SELECT RAISE(IGNORE); END;

    After this, max(id) stayed constant while the session kept working, and Codex continued to run normally. Obviously this also drops WARN/ERROR rows, which is why a real setting is needed.

    Suggestion, in line with the options above: make the log-DB filter configurable (e.g. log_db_level = "info", or "off"), and consider defaulting non-feedback sessions to INFO. If TRACE must be kept for feedback, buffering it in memory and only persisting when the user actually submits feedback would remove the steady write load entirely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    appconfigenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions