Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

example does not work when using "async or asyncConnect" options #129

Open
@mgazza

Description

When using the example with fluentd listening locally if you add Async or Async connect the message "Unable to send logs to fluentd, reconnecting..." is printed out but an strace shows that no connection is ever made.

package main
import (
	"fmt"
	"log"
	"time"
	"github.com/fluent/fluent-logger-golang/fluent"
)
func main() {
	logger, err := fluent.New(fluent.Config{FluentPort: 24224, FluentHost: "127.0.0.1", Async: true,
			MaxRetry: -1,
		})
	if err != nil {
		fmt.Println(err)
	}
	defer logger.Close()
	tag := "myapp.access"
	var data = map[string]string{
		"foo": "bar",
		"hoge": "hoge"}
	for i := 0; i < 100; i++ {
		e := logger.Post(tag, data)
		if e != nil {
			log.Println("Error while posting log: ", e)
		} else {
			log.Println("Success to post log")
		}
		time.Sleep(1000 * time.Millisecond)
	}
}
## Output without async options

2024年10月11日 12:35:31 Success to post log
2024年10月11日 12:35:32 Success to post log
2024年10月11日 12:35:33 Success to post log
2024年10月11日 12:35:34 Success to post log
2024年10月11日 12:35:35 Success to post log


## Output with asyncConnect

fluent#New: AsyncConnect is now deprecated, please use Async instead2024/10/11 12:37:20 Success to post log
[2024年10月11日T12:37:20Z] Unable to send logs to fluentd, reconnecting...
2024年10月11日 12:37:21 Success to post log
[2024年10月11日T12:37:21Z] Unable to send logs to fluentd, reconnecting...
2024年10月11日 12:37:22 Success to post log
[2024年10月11日T12:37:22Z] Unable to send logs to fluentd, reconnecting...
2024年10月11日 12:37:23 Success to post log
[2024年10月11日T12:37:23Z] Unable to send logs to fluentd, reconnecting...


## Output as per the code sample

2024年10月11日 12:37:53 Success to post log
[2024年10月11日T12:37:53Z] Unable to send logs to fluentd, reconnecting...
2024年10月11日 12:37:54 Success to post log
[2024年10月11日T12:37:54Z] Unable to send logs to fluentd, reconnecting...
2024年10月11日 12:37:55 Success to post log
[2024年10月11日T12:37:55Z] Unable to send logs to fluentd, reconnecting...
2024年10月11日 12:37:56 Success to post log
[2024年10月11日T12:37:56Z] Unable to send logs to fluentd, reconnecting...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /