Skip to content

Add independent FileLogLevels config for disk logging#369

Open
kevincw01 wants to merge 1 commit into
codeproject:mainfrom
kevincw01:file-log-levels
Open

Add independent FileLogLevels config for disk logging#369
kevincw01 wants to merge 1 commit into
codeproject:mainfrom
kevincw01:file-log-levels

Conversation

@kevincw01

@kevincw01 kevincw01 commented Jul 20, 2026

Copy link
Copy Markdown

ServerLogger currently uses a single LogLevels dictionary to gate both what's shown on the dashboard and what's written to the log file, since both come from the same Log() call. That means there's no way to keep the dashboard verbose (e.g. Information) while limiting disk writes to Warning/Error -- lowering the level to cut down on file size also silently drops entries from the live dashboard. Given SSDs are pricey these days, thats not good.

This PR adds an optional FileLogLevels dictionary (same shape as LogLevels) to appsettings.json. This is checked independently before the file write. If left unset it falls back to the existing LogLevels.

Example config to get Info+ on the dashboard but only Warning+ on disk:

"AIServer": {
  "LogLevels": { "Information": "White", "Warning": "Cyan", "Error": "Red", "Critical": "Magenta" },
  "FileLogLevels": { "Warning": "Cyan", "Error": "Red", "Critical": "Magenta" }
}

FileLogLevels uses the color syntax to preserve the same dictionary style but the colors are obviously not used.

Tested on Windows 10 x64 against v2.9.5 and current main. Confirmed via the /v1/log endpoint that a Warning entry shows in both places while an Info entry only shows on the dashboard.

ServerLogger currently gates both the dashboard's live log entry list
and the on-disk log file with a single level check (LogLevels), so
lowering verbosity to reduce disk writes also removes entries from the
live dashboard, and vice versa.

Add an optional FileLogLevels dictionary to ServerLoggerConfiguration,
mirroring the existing LogLevels dictionary. When set, it independently
gates the StoreInFile() call in StoreLogEntry(), separate from what's
shown on the dashboard. When left empty (the default), file writing
falls back to the existing LogLevels set, preserving current behavior
for anyone not using the new option.

This lets, e.g., Information+ show on the dashboard while only
Warning+ is written to disk.
@kevincw01
kevincw01 marked this pull request as ready for review July 20, 2026 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant