Logan Shire
Logan Shire

Reputation: 5103

Docker logs from go container (log and fmt) stop after init

I'm working on an application which consists of a number of go containers. I manage them with docker compose. Recently I've been having trouble getting logs out of them. When I run "docker logs [container-name]", I only see logs that were created during init for packages in my application, and during main before the service starts listening. Subsequent calls to log.Println or fmt.Println do not appear in the output of "docker logs". Do you know what could be going on?

Upvotes: 4

Views: 3979

Answers (1)

Viet Long Nguyen
Viet Long Nguyen

Reputation: 160

You may want to write your logs into the /dev/stdout or simply use

log.SetOutput(os.Stdout)

From log package

Upvotes: 2

Related Questions