简体   繁体   中英

docker log don't show python print output

I have a Django Proj running in Docker Container

My Debug=True

but docker up logging doesn't show any print('xxxx') output.

Is there a way to fix it? thanks!

After a long search I found this https://serverfault.com/a/940357

Add flush=True

print(datetime.now(), flush=True)

Or add PYTHONUNBUFFERED: 1 to docker-compose.yml which is added by PyCharm by default

version: '3.6'

services:

  test:
    ....
    environment:
      PYTHONUNBUFFERED: 1  # <---
    ....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM