>"? Can I output Django server output to a text file? eg: python manage.p...">

Is it possible to register a Django development server using cmd ">>"?

Can I output Django server output to a text file? eg:

python manage.py runserver>>Log.txt?

+3
source share
2 answers

Django uses python logging , and you can configure in yours settings.pyto output to a file.

Example for you

+4
source

You can achieve this by adding the following lines to settings.py. This will record the log file at the level DEBUG, and also display on the console in the INFOlevel.

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'file': {
            'level': 'DEBUG',
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': /path/to/django/debug.log,
            'maxBytes': 50000,
            'backupCount': 2,
        },
        'console': {
            'level': 'INFO',
            'class': 'logging.StreamHandler',
        },
    },
    'root': {
        'handlers': ['file', 'console'],
        'level': 'DEBUG'
    },
    'loggers': {
        'django': {
            'handlers': ['file', 'console'],
            'level': 'DEBUG',
            'propagate': True,
        },
    },
}

Further information can also be found in the Django documentaton .

0
source

All Articles