Logfmt 结构化日志转 JSON / NDJSON 工具

100% 浏览器本地・零服务器上传

将 Go、Heroku、Grafana Loki 的 key=val 格式 logfmt 日志流转换为格式化 JSON 与 NDJSON。

Output Format:
4 lines parsed16 unique keys
Detected Fields:level (4)ts (4)caller (4)msg (3)port (1)tls (1)method (1)path (1)status (1)duration (1)remote_ip (1)client_id (1)error (1)db_pool (1)query (1)retries (1)
Read-only preview
[
  {
    "level": "info",
    "ts": "2024-05-10T14:32:01.421Z",
    "caller": "server.go:128",
    "msg": "http server started",
    "port": 8080,
    "tls": true
  },
  {
    "level": "info",
    "ts": "2024-05-10T14:32:05.102Z",
    "caller": "router.go:54",
    "method": "GET",
    "path": "/api/v1/health",
    "status": 200,
    "duration": "1.42ms",
    "remote_ip": "10.0.4.12"
  },
  {
    "level": "warn",
    "ts": "2024-05-10T14:32:12.890Z",
    "caller": "auth.go:88",
    "msg": "invalid jwt signature",
    "client_id": "acme-corp",
    "error": "token expired"
  },
  {
    "level": "error",
    "ts": "2024-05-10T14:32:15.340Z",
    "caller": "db.go:210",
    "msg": "database query timeout",
    "db_pool": "primary",
    "query": "SELECT * FROM users",
    "retries": 3
  }
]

将此工具固定在浏览器侧边栏

随时按下 Alt+M 即可在当前标签页侧边唤出此工具,免去切网页的麻烦。100% 离线免费。

获取浏览器插件

如何将 Logfmt 日志转换为 JSON

  1. 1在左侧粘贴多行原始 logfmt 日志(如 level=info ts=... msg="server start" status=200)。
  2. 2右侧实时查看解析出的结构化 JSON 对象及键名字段统计。
  3. 3一键复制格式化 JSON 数组或用于日志系统摄取的换行 NDJSON。

Logfmt 规范背景

Logfmt 是一种紧凑且兼具人类可读性与机器易解析性的键值日志格式,广泛流行于 Go 微服务、Prometheus 及 Grafana Loki 技术栈。

常见问题解答 (FAQ)

喜欢 Logfmt 结构化日志转 JSON / NDJSON 工具 吗?分享给你的工程师朋友,一起告别广告与隐私泄露!

MiniToolDesk 100% 离线计算、零数据上传,您的支持是保持纯净无广告的动力。

相关开发者工具