Is it possible to output Django's runserver output into a text file? such as:
python manage.py runserver>>Log.txt
?
Is it possible to output Django's runserver output into a text file? such as:
python manage.py runserver>>Log.txt
?
You can achieve it by adding following lines into settings.py
.
This will both write a log file in DEBUG
level and also display on console in INFO
level.
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,
},
},
}
Please also have a look Django documentaton for additional information.