私はgolangとfluentdの初心者です。私はgithub.com/fluent/fluent-logger-golang/fluentからfluentdのロガーライブラリを使用してロギングアプリケーションを構築しようとしています。 192.168.0.106でFluentd + golangログアプリケーションでエラーが発生しています
は、サービスが実行され、以下に24224
でリッスンしているfluentd golangにログインするためのプログラムです。
package main
import (
"github.com/fluent/fluent-logger-golang/fluent"
"fmt"
)
type Student struct {
name string
id_no int
age int
}
func main() {
logger,err :=fluent.New(fluent.Config{FluentHost:"192.168.0.106", FluentPort:24224})
fmt.Println(logger.BufferLimit)
if err != nil{
fmt.Println("error creating fluentd instance")
return
}
defer logger.Close()
tag := "fluentd-log-demo"
data := Student{"John",1234,25}
error := logger.Post(tag,data)
if error != nil{
panic(error)
}
}
バイナリファイルを実行した後に大量のエラーが発生しています。
[email protected]:~/golang$ fluentd-log-demo
8388608
panic: reflect.Value.Interface: cannot return value obtained from unexported field or method
goroutine 1 [running]:
panic(0x5674e0, 0xc82000a6f0)
/home/mahesh/gotools/src/runtime/panic.go:464 +0x3e6
reflect.valueInterface(0x5674e0, 0xc820010300, 0xb8, 0x1, 0x0, 0x0)
/home/mahesh/gotools/src/reflect/value.go:919 +0xe7
reflect.Value.Interface(0x5674e0, 0xc820010300, 0xb8, 0x0, 0x0)
/home/mahesh/gotools/src/reflect/value.go:908 +0x48
github.com/fluent/fluent-logger-golang/fluent.(*Fluent).PostWithTime(0xc82007a000, 0x603120, 0x10, 0xeceb11576, 0x28abb08c, 0x6d7bc0, 0x5b2060, 0xc820010300, 0x0, 0x0)
/home/mahesh/golib/src/github.com/fluent/fluent-logger-golang/fluent/fluent.go:139 +0x315
github.com/fluent/fluent-logger-golang/fluent.(*Fluent).Post(0xc82007a000, 0x603120, 0x10, 0x5b2060, 0xc820010300, 0x0, 0x0)
/home/mahesh/golib/src/github.com/fluent/fluent-logger-golang/fluent/fluent.go:116 +0x96
main.main()
/home/mahesh/golang/src/GoBasics/fluentd-log-demo/main.go:25 +0x39e
[email protected]:~/golang$
問題のトラブルシューティングを手伝ってください。
error := logger.Post(tag,data)
data
は、それはあなた自身の構造体型で、タイプStudent
は次のとおりです。
はエラーがこの行によって引き起こされるあなた
これは機能します。あなたのコメントのためにiczaに感謝します。 –