我目前正在使用django&#39}的后端Timer
另一个post
,当我在本地开发时,它正常工作。但是,当我将它推送到使用uwsgi和nginx的暂存云服务器时,它再也无法正常工作了。我正在尝试使用api
中的print
将消息保存到文件中或以某种方式在终端中显示消息,以便我知道django
启动post response
但我有没有运气试图找到记录任何debugging
我已经在设置
中做了类似的事情print
它确实可以正常工作并正常显示消息,但我怎样也可以LOGGING = {
'version': 1,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': '/path/to/your/file.log',
'formatter': 'simple'
},
},
'loggers': {
'django': {
'handlers': ['file'],
'level': 'DEBUG',
'propagate': True,
},
}
}
进入文件?
有人可以给我一个想法或建议吗?
提前致谢
答案 0 :(得分:0)
所以看起来你已经正确设置了文件记录。唯一的事情是它不记录打印,你必须使用django的日志记录系统。像这样:
import logging
logger = logging.getLogger(__name__)
# In your code
logger.debug('Some message') # Logs as debug message
logger.error('Error message') # Logs as error message
您的记录器应将所有这些记录到文件中,因为它的级别是DEBUG
此处有更多信息:https://docs.djangoproject.com/en/2.0/topics/logging/#using-logging