[英]How to see debug logs from django-admin.py commands
I have a cron job that executes django-admin.py
command. 我有一个执行
django-admin.py
命令的cron作业。 Sometimes that command raises an exception, and I receive an email about it. 有时,该命令会引发异常,而我收到一封有关此异常的电子邮件。
The email only contains the traceback of the exception. 电子邮件仅包含异常的回溯。 But I want to also see everything that was produced via
log.debug(...)
in that run. 但是我还想看到在该运行中通过
log.debug(...)
生成的所有内容。 Is that possible? 那可能吗?
Here's my LOGGING that I use on my dev (where I was trying to reproduce it) -- so in this case I'd like to see the debug logs in the console
since I don't email myself in dev. 这是我在开发人员上使用的LOGGING(试图重现该日志的地方)-因此,在这种情况下,我想在
console
查看调试日志,因为我没有在开发人员中向自己发送电子邮件。
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'standard': {
'format' : ("[%(asctime)s] - %(levelname)s %(module)s.%(funcName)s:"
"%(lineno)s (%(name)s) %(message)s"),
'datefmt' : "%d/%b/%Y %H:%M:%S"
},
'colored': {
'format' : ("[%(asctime)s] -\033[1;35m %(levelname)s\033[0m "
"%(name)s %(funcName)s:"
"%(lineno)s \033[1m%(message)s\033[0m"),
'datefmt' : "%d/%b/%Y %H:%M:%S"
},
},
'handlers': {
'logfile': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'filename': "logfile",
'maxBytes': 50000,
'backupCount': 2,
'formatter': 'standard',
},
'console': {
'level': 'INFO',
'class': 'logging.StreamHandler',
'formatter': 'colored'
},
},
'loggers': {
'': {
'handlers': ['console', 'logfile'],
'level': 'DEBUG',
'propagate': True
},
}
}
Had to change my console logging level to allow 'DEBUG'. 必须更改我的控制台日志记录级别以允许“ DEBUG”。 Ended up removing level overwrite on the 'handlers' and just specify them per-logger.
最终删除了“处理程序”上的级别覆盖,只为每个记录器指定了它们。 Added specific loggers for management commands rather than just use a catch-all logger.
添加了用于管理命令的特定记录器,而不仅仅是使用全部记录器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.