登录 注册

zerolog

去点 Star
其他 golangjsonloggingstructured-loggingzerolog
12,536
Stars
661
Forks
71
Watchers
169
Open Issues
MIT
许可证
Go
语言
2017-05-12
创建时间
2026-11-10
最近更新

项目能做什么

专为 Go 打造的零内存分配高性能 JSON 日志库。
来源:AI 基于仓库事实生成 · 内容以仓库实际 README 为准

使用说明 查看原始 README 原仓库文档

中文使用说明暂未生成。下面保留原仓库 README 摘录,命令与配置均以原文为准。
原始 README 摘录(英文原文,节选前 3000 字符)
# Zero Allocation JSON Logger

[![godoc](http://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/rs/zerolog) [![license](http://img.shields.io/badge/license-MIT-red.svg?style=flat)](https://raw.githubusercontent.com/rs/zerolog/master/LICENSE) [![Build Status](https://github.com/rs/zerolog/actions/workflows/test.yml/badge.svg)](https://github.com/rs/zerolog/actions/workflows/test.yml) [![Go Coverage](https://github.com/rs/zerolog/wiki/coverage.svg)](https://raw.githack.com/wiki/rs/zerolog/coverage.html)

The zerolog package provides a fast and simple logger dedicated to JSON output.

Zerolog's API is designed to provide both a great developer experience and stunning [performance](#benchmarks). Its unique chaining API allows zerolog to write JSON (or CBOR) log events by avoiding allocations and reflection.

Uber's [zap](https://godoc.org/go.uber.org/zap) library pioneered this approach. Zerolog is taking this concept to the next level with a simpler to use API and even better performance.

To keep the code base and the API simple, zerolog focuses on efficient structured logging only. Pretty logging on the console is made possible using the provided (but inefficient) [`zerolog.ConsoleWriter`](#pretty-logging).

![Pretty Logging Image](pretty.png)

## Who uses zerolog

Find out [who uses zerolog](https://github.com/rs/zerolog/wiki/Who-uses-zerolog) and add your company / project to the list.

## Features

- [Blazing fast](#benchmarks)
- [Low to zero allocation](#benchmarks)
- [Leveled logging](#leveled-logging)
- [Sampling](#log-sampling)
- [Hooks](#hooks)
- [Contextual fields](#contextual-logging)
- [`context.Context` integration](#contextcontext-integration)
- [Integration with `net/http`](#integration-with-nethttp)
- [JSON and CBOR encoding formats](#binary-encoding)
- [Pretty logging for development](#pretty-logging)
- [Error Logging (with optional Stacktrace)](#error-logging)
- [`log/slog` integration](#integration-with-logslog)

## Installation

```bash
go get -u github.com/rs/zerolog/log
```

## Getting Started

### Simple Logging Example

For simple logging, import the global logger package **github.com/rs/zerolog/log**

```go
package main

import (
    "github.com/rs/zerolog"
    "github.com/rs/zerolog/log"
)

func main() {
    // UNIX Time is faster and smaller than most timestamps
    zerolog.TimeFieldFormat = zerolog.TimeFormatUnix

    log.Print("hello world")
}

// Output: {"time":1516134303,"level":"debug","message":"hello world"}
```

> Note: By default log writes to `os.Stderr`
> Note: The default log level for `log.Print` is _trace_

### Contextual Logging

**zerolog** allows data to be added to log messages in the form of key:value pairs. The data added to the message adds "context" about the log event that can be critical for debugging as well as myriad other purposes. An example of this is below:

```go
package main

import (
    "github.com/rs/zerolog"
    "github.com/rs/zerolog/log"
)

fun
阅读完整原文

商业机会分析 AI 生成

Zerolog 原生的高性能轻量日志分析与可视化终端/GUI 工具

产品构想针对开发和本地排查场景,打造无缝解析 zerolog 结构化 JSON/CBOR 格式的桌面端/CLI 增强工具,提供低延迟流式过滤、字段提取及漂亮渲染(替代其内置较慢的 ConsoleWriter)。
核心功能毫秒级实时日志流监听、CBOR/JSON 二进制免配置解析、多字段组合条件过滤、异常堆栈树形展示、团队共享过滤规则与会话回放。
目标用户使用 zerolog 进行日常开发、联调排障的 Go 开发者与测试人员。
难度/周期中等 · 2-3 个月 · 成本:极低(主要为客户端开发人力与打包签名费用)
收费模式免费开源 CLI 基础版 + 商业闭源 GUI Pro 桌面版(单机买断/订阅许可)。
竞争风险竞争对手包括开源现成的 jq、lnav 或通用日志收集器,纯客户端工具付费壁垒较低。
依据 已验证事实

云原生 Zerolog 安全与数据合规中间件(SaaS/Agent)

产品构想构建与 zerolog Hook/Writer 深度集成的合规中间件,在日志输出前自动完成 PII(个人隐私数据)脱敏、合规审计、动态采样,并以极低开销上报到合规中心。
核心功能零额外分配的正则/模式敏感信息脱敏 Hook、动态远程调整日志等级与采样规则、合规性审计报表、审计溯源与加密归档。
目标用户金融科技、出海业务(GDPR/HIPAA 要求)的企业研发负责人与安全合规团队。
难度/周期高 · 4-6 个月 · 成本:中等(需维护合规规则库及安全鉴权后端)
收费模式企业级年费订阅(按接入节点数或数据吞吐量计费)。
竞争风险推测:大型企业更倾向于在网关或统一日志中心做脱敏,而非侵入业务代码层;对 agent 的性能与稳定性要求极高。
依据 AI推测

企业级 Go 系统高并发性能优化与可观测性咨询服务

产品构想以 zerolog 的高性能为技术信任背书,提供 Go 语言微服务架构下的高并发性能压测、内存零分配调优、可观测性(Logging + OpenTelemetry)落地咨询与定制开发。
核心功能Go 代码性能与内存泄漏审计、基于 zerolog + slog 的统一日志规范建设、全链路 Trace 注入改造、定制专属 Log Writer(直接落盘优化/专用网络协议)。
目标用户遇到 GC 瓶颈、高并发日志 IO 卡顿的大中型互联网公司及技术团队。
难度/周期中等 · 按项目交付(单次 2-4 周) · 成本:低(主要为专家时间成本)
收费模式技术咨询服务费、企业内训按天计费、性能保标合同分成。
竞争风险咨询业务难以规模化扩张,高度依赖个人/团队口碑和商机拓展能力。
依据 数据支持的判断
AI 基于仓库公开数据分析生成,含推测成分,不构成收益承诺。
报告会保存到 个人中心

竞品与相似项目 GitHub Search 真实检索

项目中文简介Stars语言
practical-tutorials/project-based-learning 中文介绍暂未生成
Curated list of project-based tutorials
289,536 Python
avelino/awesome-go 中文介绍暂未生成
A curated list of awesome Go frameworks, libraries and softw
193,296 Go
ollama/ollama 中文介绍暂未生成
Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-os
186,663 Go
golang/go 中文介绍暂未生成
The Go programming language
139,795 Go
caddyserver/caddy 中文介绍暂未生成
Fast and extensible multi-platform HTTP/1-2-3 web server wit
78,974 Go
unionlabs/union 中文介绍暂未生成
The trust-minimized, zero-knowledge bridging protocol, desig
73,716 Rust
以上为通过 GitHub 官方 Search API 检索的相似项目,功能差异与优劣势需进一步人工确认,配置 AI 后可生成对比分析。

项目优势与风险

技术成熟度创建于 2017-05-12,近 30 天仍在推送
社区活跃Star 12,536 / Fork 661 / Issue 169(数据支持,可自行核实)
许可证MIT
主要风险上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价

安装与使用

快速开始(以仓库 README 为准)
git clone https://github.com/rs/zerolog.git
cd zerolog
# 请阅读仓库 README 获取确切安装步骤(依赖、配置、启动命令)
阅读原仓库文档
术语说明:Docker=应用容器(把程序和依赖打包运行);API Key=调用外部服务的密钥;Git Clone=把仓库代码下载到本地。常见错误:API Key 未配置 / 端口占用 / 数据库连接失败,多数项目在 README 的 Troubleshooting 章节有说明。