我在生产服务器上登录时遇到一些问题。我的设置.py看起来像这样:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'simple': {
'format': '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
},
},
'handlers': {
# Log to a text file that can be rotated by logrotate
'logfile': {
'class': 'logging.handlers.WatchedFileHandler',
'filename': 'logs/main.log',
'formatter': 'simple',
'mode': 'w',
},
},
'loggers': {
# Again, default Django configuration to email unhandled exceptions
'django.request': {
'handlers': ['logfile'],
'level': 'DEBUG',
'propagate': True,
},
# Might as well log any errors anywhere else in Django
'django': {
'handlers': ['logfile'],
'level': 'DEBUG',
'propagate': True,
},
# Your own app - this assumes all your logger names start with "myapp."
'myapp': {
'handlers': ['logfile'],
'level': 'DEBUG',
'propagate': True
},
},
}
如果我在本地主机上测试它,我会得到:
^{2}$但是,如果我用nginx在生产服务器上测试,gunicorn会得到:
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): www.googleapis.com
这些只是第一行。我的问题是为什么我得到两个不同的输出?在
我能提供其他必要的信息吗?是否有可能覆盖设置.py文件?在
是否需要进行特定的生产日志记录配置?在
如有任何帮助,我们将不胜感激。。。。希望有人以前有过这样的错误或问题。在
编辑:我使用'w'模式,在本地主机上,如果我重新加载服务器,我的日志文件就会被清除,在生产端,它不会被清除。在
这是否意味着我需要重新启动/重新装载gunicorn?在
重新启动并重新加载gunicorn解决了这个问题。哇哈哈
相关问题 更多 >
编程相关推荐