[PR #15216] logutil: support JSON log output via OLLAMA_LOG_FORMAT #77376

Open
opened 2026-05-05 10:03:12 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/15216
Author: @dhirajlochib
Created: 4/2/2026
Status: 🔄 Open

Base: mainHead: logutil/json-log-format


📝 Commits (1)

  • fef7c62 logutil: support JSON log output via OLLAMA_LOG_FORMAT

📊 Changes

3 files changed (+75 additions, -2 deletions)

View changed files

📝 envconfig/config.go (+3 -0)
📝 logutil/logutil.go (+11 -2)
logutil/logutil_test.go (+61 -0)

📄 Description

Closes #14018

Add support for structured JSON log output by setting:

OLLAMA_LOG_FORMAT=json

The default text format is unchanged. The value is case-insensitive (JSON, json, Json all work). Any unrecognised value falls back to text.

The env var is read directly via os.Getenv in logutil to avoid a circular import with envconfig. A LogFormat var is also added to envconfig so the variable appears in ollama serve env var listings.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/15216 **Author:** [@dhirajlochib](https://github.com/dhirajlochib) **Created:** 4/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `logutil/json-log-format` --- ### 📝 Commits (1) - [`fef7c62`](https://github.com/ollama/ollama/commit/fef7c6201dc1c27b6a564dcf39e5aca1af7cd124) logutil: support JSON log output via OLLAMA_LOG_FORMAT ### 📊 Changes **3 files changed** (+75 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `envconfig/config.go` (+3 -0) 📝 `logutil/logutil.go` (+11 -2) ➕ `logutil/logutil_test.go` (+61 -0) </details> ### 📄 Description Closes #14018 Add support for structured JSON log output by setting: ``` OLLAMA_LOG_FORMAT=json ``` The default text format is unchanged. The value is case-insensitive (`JSON`, `json`, `Json` all work). Any unrecognised value falls back to text. The env var is read directly via `os.Getenv` in `logutil` to avoid a circular import with `envconfig`. A `LogFormat` var is also added to `envconfig` so the variable appears in `ollama serve` env var listings. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-05 10:03:12 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#77376