The goal of efficiency is more slack.

Monday, September 25, 2017

Logging in Django

To log to console in Django. Source: Logging | djangoproject.com

settings.py 

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'console': {
            'class': 'logging.StreamHandler',
        },
    },
    'loggers': {
        'django': {
            'handlers': ['console'],
            'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
        },
    },
}

File that uses logging

import logging
logger = logging.getLogger('django')

Write to log

logger.info('Hello')

Related Posts:

  • Django in a subdirectoryHow to serve a Django project as a subdirectory of another Django project's URL. For example, the first Django site is at www.example.com/ and the sec… Read More
  • FeinCMS installationFollowing directions at https://feincms-django-cms.readthedocs.io/en/stable/installation.html, I ran into some problems, probably due to a Django vers… Read More
  • Create a new Django project in VSCode Go to user settings (cmd-,): "python.venvPath": "~/.virtualenvs", Quit VSCode. Open a Python file in VSCode. Select virtualenv in bottom ba… Read More
  • Install Django on a development MacNotes on installing a Django development environment on a Mac. Install Python Install Python 3 from www.python.org. Run Install Cerltificates.comm… Read More
  • Django settings in wsgi.pyIn wsgi.py, don't use os.environ.setdefault because another uwsgi vassal may have set the environ already. Set the dictionary directly. os.environ['D… Read More

0 comments:

Popular Posts

Recent Posts

Unordered List

Text Widget

Pages

Powered by Blogger.
Scroll To Top