{"id":13397155,"url":"https://github.com/uber-go/zap","last_synced_at":"2025-09-09T21:05:40.318Z","repository":{"id":37382072,"uuid":"52034309","full_name":"uber-go/zap","owner":"uber-go","description":"Blazing fast, structured, leveled logging in Go.","archived":false,"fork":false,"pushed_at":"2025-03-24T17:13:34.000Z","size":1964,"stargazers_count":23040,"open_issues_count":161,"forks_count":1473,"subscribers_count":249,"default_branch":"master","last_synced_at":"2025-05-13T10:59:45.170Z","etag":null,"topics":["golang","logging","structured-logging","zap"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/go.uber.org/zap","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uber-go.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-18T19:52:56.000Z","updated_at":"2025-05-13T10:03:31.000Z","dependencies_parsed_at":"2023-11-25T07:25:23.335Z","dependency_job_id":"570247b1-001e-4310-95a5-6c9b5481a24d","html_url":"https://github.com/uber-go/zap","commit_stats":{"total_commits":673,"total_committers":160,"mean_commits":4.20625,"dds":0.8736998514115899,"last_synced_commit":"0ba452dbe15478739ad4bab1067706018a3062c6"},"previous_names":["uber-common/zap"],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uber-go%2Fzap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uber-go%2Fzap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uber-go%2Fzap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uber-go%2Fzap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uber-go","download_url":"https://codeload.github.com/uber-go/zap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253929358,"owners_count":21985802,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","logging","structured-logging","zap"],"created_at":"2024-07-30T18:01:11.909Z","updated_at":"2025-05-13T11:00:05.281Z","avatar_url":"https://github.com/uber-go.png","language":"Go","readme":"# :zap: zap\n\n\n\u003cdiv align=\"center\"\u003e\n\nBlazing fast, structured, leveled logging in Go.\n\n![Zap logo](assets/logo.png)\n\n[![GoDoc][doc-img]][doc] [![Build Status][ci-img]][ci] [![Coverage Status][cov-img]][cov]\n\n\u003c/div\u003e\n\n## Installation\n\n`go get -u go.uber.org/zap`\n\nNote that zap only supports the two most recent minor versions of Go.\n\n## Quick Start\n\nIn contexts where performance is nice, but not critical, use the\n`SugaredLogger`. It's 4-10x faster than other structured logging\npackages and includes both structured and `printf`-style APIs.\n\n```go\nlogger, _ := zap.NewProduction()\ndefer logger.Sync() // flushes buffer, if any\nsugar := logger.Sugar()\nsugar.Infow(\"failed to fetch URL\",\n  // Structured context as loosely typed key-value pairs.\n  \"url\", url,\n  \"attempt\", 3,\n  \"backoff\", time.Second,\n)\nsugar.Infof(\"Failed to fetch URL: %s\", url)\n```\n\nWhen performance and type safety are critical, use the `Logger`. It's even\nfaster than the `SugaredLogger` and allocates far less, but it only supports\nstructured logging.\n\n```go\nlogger, _ := zap.NewProduction()\ndefer logger.Sync()\nlogger.Info(\"failed to fetch URL\",\n  // Structured context as strongly typed Field values.\n  zap.String(\"url\", url),\n  zap.Int(\"attempt\", 3),\n  zap.Duration(\"backoff\", time.Second),\n)\n```\n\nSee the [documentation][doc] and [FAQ](FAQ.md) for more details.\n\n## Performance\n\nFor applications that log in the hot path, reflection-based serialization and\nstring formatting are prohibitively expensive \u0026mdash; they're CPU-intensive\nand make many small allocations. Put differently, using `encoding/json` and\n`fmt.Fprintf` to log tons of `interface{}`s makes your application slow.\n\nZap takes a different approach. It includes a reflection-free, zero-allocation\nJSON encoder, and the base `Logger` strives to avoid serialization overhead\nand allocations wherever possible. By building the high-level `SugaredLogger`\non that foundation, zap lets users *choose* when they need to count every\nallocation and when they'd prefer a more familiar, loosely typed API.\n\nAs measured by its own [benchmarking suite][], not only is zap more performant\nthan comparable structured logging packages \u0026mdash; it's also faster than the\nstandard library. Like all benchmarks, take these with a grain of salt.\u003csup\nid=\"anchor-versions\"\u003e[1](#footnote-versions)\u003c/sup\u003e\n\nLog a message and 10 fields:\n\n| Package | Time | Time % to zap | Objects Allocated |\n| :------ | :--: | :-----------: | :---------------: |\n| :zap: zap | 656 ns/op | +0% | 5 allocs/op\n| :zap: zap (sugared) | 935 ns/op | +43% | 10 allocs/op\n| zerolog | 380 ns/op | -42% | 1 allocs/op\n| go-kit | 2249 ns/op | +243% | 57 allocs/op\n| slog (LogAttrs) | 2479 ns/op | +278% | 40 allocs/op\n| slog | 2481 ns/op | +278% | 42 allocs/op\n| apex/log | 9591 ns/op | +1362% | 63 allocs/op\n| log15 | 11393 ns/op | +1637% | 75 allocs/op\n| logrus | 11654 ns/op | +1677% | 79 allocs/op\n\nLog a message with a logger that already has 10 fields of context:\n\n| Package | Time | Time % to zap | Objects Allocated |\n| :------ | :--: | :-----------: | :---------------: |\n| :zap: zap | 67 ns/op | +0% | 0 allocs/op\n| :zap: zap (sugared) | 84 ns/op | +25% | 1 allocs/op\n| zerolog | 35 ns/op | -48% | 0 allocs/op\n| slog | 193 ns/op | +188% | 0 allocs/op\n| slog (LogAttrs) | 200 ns/op | +199% | 0 allocs/op\n| go-kit | 2460 ns/op | +3572% | 56 allocs/op\n| log15 | 9038 ns/op | +13390% | 70 allocs/op\n| apex/log | 9068 ns/op | +13434% | 53 allocs/op\n| logrus | 10521 ns/op | +15603% | 68 allocs/op\n\nLog a static string, without any context or `printf`-style templating:\n\n| Package | Time | Time % to zap | Objects Allocated |\n| :------ | :--: | :-----------: | :---------------: |\n| :zap: zap | 63 ns/op | +0% | 0 allocs/op\n| :zap: zap (sugared) | 81 ns/op | +29% | 1 allocs/op\n| zerolog | 32 ns/op | -49% | 0 allocs/op\n| standard library | 124 ns/op | +97% | 1 allocs/op\n| slog | 196 ns/op | +211% | 0 allocs/op\n| slog (LogAttrs) | 200 ns/op | +217% | 0 allocs/op\n| go-kit | 213 ns/op | +238% | 9 allocs/op\n| apex/log | 771 ns/op | +1124% | 5 allocs/op\n| logrus | 1439 ns/op | +2184% | 23 allocs/op\n| log15 | 2069 ns/op | +3184% | 20 allocs/op\n\n## Development Status: Stable\n\nAll APIs are finalized, and no breaking changes will be made in the 1.x series\nof releases. Users of semver-aware dependency management systems should pin\nzap to `^1`.\n\n## Contributing\n\nWe encourage and support an active, healthy community of contributors \u0026mdash;\nincluding you! Details are in the [contribution guide](CONTRIBUTING.md) and\nthe [code of conduct](CODE_OF_CONDUCT.md). The zap maintainers keep an eye on\nissues and pull requests, but you can also report any negative conduct to\noss-conduct@uber.com. That email list is a private, safe space; even the zap\nmaintainers don't have access, so don't hesitate to hold us to a high\nstandard.\n\n\u003chr\u003e\n\nReleased under the [MIT License](LICENSE).\n\n\u003csup id=\"footnote-versions\"\u003e1\u003c/sup\u003e In particular, keep in mind that we may be\nbenchmarking against slightly older versions of other packages. Versions are\npinned in the [benchmarks/go.mod][] file. [↩](#anchor-versions)\n\n[doc-img]: https://pkg.go.dev/badge/go.uber.org/zap\n[doc]: https://pkg.go.dev/go.uber.org/zap\n[ci-img]: https://github.com/uber-go/zap/actions/workflows/go.yml/badge.svg\n[ci]: https://github.com/uber-go/zap/actions/workflows/go.yml\n[cov-img]: https://codecov.io/gh/uber-go/zap/branch/master/graph/badge.svg\n[cov]: https://codecov.io/gh/uber-go/zap\n[benchmarking suite]: https://github.com/uber-go/zap/tree/master/benchmarks\n[benchmarks/go.mod]: https://github.com/uber-go/zap/blob/master/benchmarks/go.mod\n\n","funding_links":[],"categories":["Go","Logging","开源类库","Log","Misc","Backend Go","Programming Languages","Go (134)","Uncategorized","Open source library","Go Tools and Frameworks","Library","Go Tools","语言资源库","日志","Go 程序设计","Backend frameworks \u0026 libraries","Logging 日志库","Relational Databases","Popular","\u003cspan id=\"日志-logging\"\u003e日志 Logging\u003c/span\u003e","Tools","日志库","日志记录","Libraries","\u003ca name=\"Go\"\u003e\u003c/a\u003eGo"],"sub_categories":["Search and Analytic Databases","日志","Advanced Console UIs","Logging","Golang","Uncategorized","Logs","Interfaces","go","网络服务_其他","SQL 查询语句构建库","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","E-Books","Mesh networks","JavaScript Libraries for Machine Learning","检索及分析资料库","交流"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuber-go%2Fzap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuber-go%2Fzap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuber-go%2Fzap/lists"}