[PR #14472] logutil: add JSON logging format via OLLAMA_LOG_FORMAT #40570

Open
opened 2026-04-23 01:26:28 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14472
Author: @Anandesh-Sharma
Created: 2/26/2026
Status: 🔄 Open

Base: mainHead: feat-json-logging


📝 Commits (1)

  • aedebae logutil: add JSON logging format via OLLAMA_LOG_FORMAT

📊 Changes

2 files changed (+12 additions, -2 deletions)

View changed files

📝 envconfig/config.go (+1 -0)
📝 logutil/logutil.go (+11 -2)

📄 Description

Summary

  • Adds support for structured JSON log output by setting OLLAMA_LOG_FORMAT=json
  • Uses Go's standard slog.JSONHandler for the JSON format
  • Registers OLLAMA_LOG_FORMAT in the environment variable display (ollama serve startup output)
  • Default behavior (text format) is unchanged

Usage

OLLAMA_LOG_FORMAT=json ollama serve

Example JSON output

{"time":"2026-02-27T10:00:00.000Z","level":"INFO","source":{"function":"...","file":"routes.go","line":1663},"msg":"server config","env":{...}}

This enables integration with structured log aggregation systems like ELK, Splunk, Grafana Loki, or any system that consumes JSON logs.

Fixes #14018


🔄 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/14472 **Author:** [@Anandesh-Sharma](https://github.com/Anandesh-Sharma) **Created:** 2/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat-json-logging` --- ### 📝 Commits (1) - [`aedebae`](https://github.com/ollama/ollama/commit/aedebae619f2167bfbec02d4f5bed65fc17518f7) logutil: add JSON logging format via OLLAMA_LOG_FORMAT ### 📊 Changes **2 files changed** (+12 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `envconfig/config.go` (+1 -0) 📝 `logutil/logutil.go` (+11 -2) </details> ### 📄 Description ## Summary - Adds support for structured JSON log output by setting `OLLAMA_LOG_FORMAT=json` - Uses Go's standard `slog.JSONHandler` for the JSON format - Registers `OLLAMA_LOG_FORMAT` in the environment variable display (`ollama serve` startup output) - Default behavior (text format) is unchanged ### Usage ```bash OLLAMA_LOG_FORMAT=json ollama serve ``` ### Example JSON output ```json {"time":"2026-02-27T10:00:00.000Z","level":"INFO","source":{"function":"...","file":"routes.go","line":1663},"msg":"server config","env":{...}} ``` This enables integration with structured log aggregation systems like ELK, Splunk, Grafana Loki, or any system that consumes JSON logs. Fixes #14018 --- <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-04-23 01:26:28 -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#40570