title: How do I write logs to docker container in a Django project?
body: <p>I am trying to configure my local logger to write the logs to docker container, so I can see the logs in the list displayed by the command <code>docker[-compose] logs &lt;container&gt; --tail 100</code></p>
  <p>In <code>settings.py</code>, I configured <code>LOGGING</code> variable like this:</p>
  <pre><code> LOGGING = {
      'version': 1,
      'disable_existing_loggers': False,
      'formatters': {
          'default': {
              'format': '[DJANGO] %(levelname)s %(asctime)s %(module)s '
                        '%(name)s.%(funcName)s:%(lineno)s: %(message)s'
          },
      },
      'handlers': {
          'console': {
              'level': 'DEBUG',
              'class': 'logging.StreamHandler',
              'formatter': 'default',
          }
      },
      'loggers': {
          '': {
              'handlers': ['console'],
              'level': 'DEBUG',
              'propagate': True,
          }
      },
  }
  </code></pre>
  <p>In the files where I need the loggers, at the beginning, I am writing:</p>
  <pre><code>import logging
  logger = logging.getLogger(__name__)
  </code></pre>
  <p>Then, in my code where I need it I write:</p>
  <pre><code>.......
  logger.error('something happened')
  .......
  </code></pre>
  <p>As I configured my logger, the log will be displayed in the console. But my problem is:</p>
  <p>How can I display it in docker container when I call the aforementioned command ?</p>
  <p>Example like desired output:</p>
  <pre><code>........
  web_1 | [2022-02-23 17:37:10 +0200] [9] [INFO] ASGI 'lifespan' protocol appears unsupported.
  web_1 | [2022-02-23 17:37:10 +0200] [9] [INFO] Application startup complete.
  web_1 | [2022-02-23 17:37:10 +0200] [10] [INFO] Application startup complete.
  web_1 | My log somewhere here..
  ........
  </code></pre>
  <p>Thank you very much !</p>