https://github.com/bolcom/log15-redis-handler
handler for the log15 package that sends JSON messages in Logstash format to a Redis queue
https://github.com/bolcom/log15-redis-handler
Last synced: 11 months ago
JSON representation
handler for the log15 package that sends JSON messages in Logstash format to a Redis queue
- Host: GitHub
- URL: https://github.com/bolcom/log15-redis-handler
- Owner: bolcom
- License: other
- Created: 2017-02-14T15:37:19.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-20T08:11:36.000Z (over 9 years ago)
- Last Synced: 2025-04-02T07:28:05.643Z (about 1 year ago)
- Language: Go
- Size: 10.7 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# log15-redis-handler (package redis15)
[](https://travis-ci.org/bolcom/log15-redis-handler)
[](https://goreportcard.com/report/github.com/bolcom/log15-redis-handler)
[](https://godoc.org/github.com/bolcom/log15-redis-handler)
## How to send log messages to Logstash via Redis
package main
import (
"os"
redis15 "github.com/bolcom/log15-redis-handler"
"github.com/inconshreveable/log15"
)
func main() {
logger := log15.New()
f := redis15.LogstashFormat{}
f.Application = "daxy"
f.Role = "webservice"
f.Instance = "ps34"
f.SourceHost = "MacErnest"
f.Pretty = true // e.g. hook to verbose flag
redisHandler , _ := NewRedisHandler([]string{"localhost:6379}, "logs", f)
// must handle err
logger.SetHandler(redisHandler)
logger.Debug("hello", "pi", 3.14)
}
Example output
{
"@source_host": "MacErnest",
"@timestamp": "2017-02-17T09:57:37.028587577+01:00",
"@fields": {
"application": "daxy",
"file": "redis15.go",
"instance": "ps34",
"level": "DEBUG",
"line": "22",
"pi": "3.14",
"role": "webservice"
},
"@message": "hello"
}
Note that most values are converted to a String.
Use NoStringConvert on the LogstashFormat value to specify the exceptions.
For application logging, the `logtype`, `level` and `message` are reserved.
© 2017 bol.com. Apache v2 Licensed. Contributions are welcome.