https://github.com/apex/log
Structured logging package for Go.
https://github.com/apex/log
apex-logs golang logger logging
Last synced: 3 days ago
JSON representation
Structured logging package for Go.
- Host: GitHub
- URL: https://github.com/apex/log
- Owner: apex
- License: mit
- Created: 2015-12-21T20:27:48.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-11-03T18:30:34.000Z (over 1 year ago)
- Last Synced: 2025-04-03T01:30:20.545Z (10 days ago)
- Topics: apex-logs, golang, logger, logging
- Language: Go
- Homepage:
- Size: 110 KB
- Stars: 1,370
- Watchers: 35
- Forks: 113
- Open Issues: 46
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-go - log - Structured logging package for Go. (Logging / Search and Analytic Databases)
- awesome-github-star - log
- awesome-go - log - Structured logging package for Go. Stars:`1.4K`. (Logging / Search and Analytic Databases)
- awesome-go - log - Structured logging package for Go. - ★ 621 (Logging)
- awesome-go-extra - log - 12-21T20:27:48Z|2022-06-20T10:43:29Z| (Logging / Advanced Console UIs)
- awesome-go-zh - log
README

Package log implements a simple structured logging API inspired by Logrus, designed with centralization in mind. Read more on [Medium](https://medium.com/@tjholowaychuk/apex-log-e8d9627f4a9a#.rav8yhkud).
## Handlers
- __apexlogs__ – handler for [Apex Logs](https://apex.sh/logs/)
- __cli__ – human-friendly CLI output
- __discard__ – discards all logs
- __es__ – Elasticsearch handler
- __graylog__ – Graylog handler
- __json__ – JSON output handler
- __kinesis__ – AWS Kinesis handler
- __level__ – level filter handler
- __logfmt__ – logfmt plain-text formatter
- __memory__ – in-memory handler for tests
- __multi__ – fan-out to multiple handlers
- __papertrail__ – Papertrail handler
- __text__ – human-friendly colored output
- __delta__ – outputs the delta between log calls and spinner## Example
Example using the [Apex Logs](https://apex.sh/logs/) handler.
```go
package mainimport (
"errors"
"time""github.com/apex/log"
)func main() {
ctx := log.WithFields(log.Fields{
"file": "something.png",
"type": "image/png",
"user": "tobi",
})for range time.Tick(time.Millisecond * 200) {
ctx.Info("upload")
ctx.Info("upload complete")
ctx.Warn("upload retry")
ctx.WithError(errors.New("unauthorized")).Error("upload failed")
ctx.Errorf("failed to upload %s", "img.png")
}
}
```---
[](https://semaphoreci.com/tj/log)
[](https://godoc.org/github.com/apex/log)

