# Overview

# zerolog {#zerolog}


zerolog provides a fast and simple logger dedicated to JSON output for Go. It is designed around the idea that structured logging should not cost allocations: the library uses a lock-free, zero-allocation JSON encoder, which makes it one of the fastest logging options in the Go ecosystem while keeping a familiar, chainable API.


## Why zerolog {#why-zerolog}


The library's promise is stated by its benchmark suite: zerolog's JSON encoder is faster than the standard library's `encoding/json` and most structured loggers because it builds events in a reusable byte buffer instead of allocating intermediate maps. Log levels (`trace`, `debug`, `info`, `warn`, `error`, `fatal`, `panic`, and `no` level), contextual sub-loggers, error events with stack traces, sampling, and hooks are all part of the core. Binary encoding via CBOR is available through `internal/cbor`-backed helpers for consumers that need compact output.


## Install {#install}


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

The module has no external dependencies. Import the `log` subpackage for the global logger, or use the root `zerolog` package directly when you manage your own `Logger` instances.


## Quick start {#quick-start}


```go
package main

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

func main() {
    zerolog.TimeFieldFormat = zerolog.TimeFormatUnix

    log.Debug().
        Int("port", 8080).
        Msg("server starting")
}
```

The chainable event API means every typed field call (`Str`, `Int`, `Err`, `Dict`, `Array`, ...) mutates the current event and returns it, so building rich structured entries reads top-to-bottom without allocations.


## Where to go next {#where-to-go-next}


The [Go API reference](https://makar52nn2016.codeberg.page/zerolog-docs/api/index.md) documents all 13 packages of the module, including the root `zerolog` package (events, contexts, writers, sampling), the `log` global logger, `hlog` HTTP helpers, `diode` lock-free ring buffers for concurrent writers, `journald` systemd integration, and `pkgerrors` stack-trace marshalling. Every entry carries its source signature and, where present, example code extracted from the module's own `*_test.go` files.


## About this site {#about-this-site}


This documentation is a Sourcey-generated mirror of the `github.com/rs/zerolog` module's godoc, built from the module source at a pinned commit. It exists to make zerolog's full API surface browsable, searchable, and agent-readable (`llms.txt`) in one static site.
