# README
Axiom Go Adapter for rs/zerolog
Adapter to ship logs generated by rs/zerolog to Axiom.
Quickstart
Follow the Axiom Go Quickstart to install the Axiom Go package and configure your environment.
Import the package:
// Imported as "adapter" to not conflict with the "rs/zerolog" package.
import adapter "github.com/axiomhq/axiom-go/adapters/zerolog"
You can also configure the adapter using options passed to the New function:
writer, err := adapter.New(
WithDatasetName("logs"),
)
l.Logger = zerolog.New(io.MultiWriter(writer, os.Stderr)).With().Str("env", os.Getenv("ENV")).Timestamp().Logger()
To configure the underlying client manually either pass in a client that was created according to the Axiom Go Quickstart using SetClient or pass client options to the adapter using SetClientOptions.
import (
"github.com/axiomhq/axiom-go/axiom"
adapter "github.com/axiomhq/axiom-go/adapters/zerolog"
)
// ...
writer, err := adapter.New()
if err != nil {
log.Fatal(err)
}
l.Logger = zerolog.New(io.MultiWriter(writer, os.Stderr)).With().Str("env", os.Getenv("ENV")).Timestamp().Logger()
[!IMPORTANT] The adapter uses a buffer to batch events before sending them to Axiom. This buffer can be flushed explicitly by calling Close, and is necessary when terminating the program so as not to lose logs. If With().Timestamp() isn't passed, then the timestamp will be the batched timestamp on the server Checkout out the example.