go logstash
expose Logger struct
Logstash Logger 用 Go 编写,将日志直接推送到 Logstash。它支持以 JSON 格式和字符串格式将输出写入 Logstash。
go get github.com/KaranJagtiani/go-logstash
import "github.com/KaranJagtiani/go-logstash"
logstash_logger
实例: logger := logstash_logger. Init ( "<host>" , < port > , "protocol" , < timeout > )
logstash_logger.Init()
具有以下配置选项:
例子:
logger := logstash_logger . Init ( "logstash" , 5228 , "udp" , 5 )
payload := map [ string ] interface {}{
"message" : "test message" ,
"error" : false ,
}
// Generic - For logging the payload as it is
logger . Log ( payload )
// Adds a attribute called "severity": "INFO" to the payload
logger . Info ( payload )
// Adds a attribute called "severity": "DEBUG" to the payload
logger . Debug ( payload )
// Adds a attribute called "severity": "WARN" to the payload
logger . Warn ( payload )
// Adds a attribute called "severity": "ERROR" to the payload
logger . Error ( payload )
// For sending a string message to Logstash
logger . LogString ( "String Message" )
欢迎为 go-logstash 做出贡献!如果您发现错误或想要添加新功能,请在 GitHub 上创建问题或提交拉取请求。