Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

docker

go

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?

like image 623
Logan Shire Avatar asked Oct 22 '25 06:10

Logan Shire


1 Answers

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

log.SetOutput(os.Stdout)

From log package

like image 100
Viet Long Nguyen Avatar answered Oct 23 '25 20:10

Viet Long Nguyen