5

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!

C.K.
  • 4,348
  • 29
  • 43
  • https://stackoverflow.com/questions/29663459/python-app-does-not-print-anything-when-running-detached-in-docker/ – atline Nov 26 '20 at 01:46

1 Answers1

12

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  # <---
    ....
C.K.
  • 4,348
  • 29
  • 43