我有一个在Dotcloud上运行的 Django 应用程序。我已尝试添加Logentries日志记录,该日志记录在我的网站正常使用中有效,但导致我的 cron 作业因此错误而失败 -
Traceback (most recent call last):
File "/home/dotcloud/current/my_project/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/dotcloud/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/home/dotcloud/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/dotcloud/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command
commands = get_commands()
File "/home/dotcloud/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 107, in get_commands
apps = settings.INSTALLED_APPS
File "/home/dotcloud/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 54, in __getattr__
self._setup(name)
File "/home/dotcloud/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 50, in _setup
self._configure_logging()
File "/home/dotcloud/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 80, in _configure_logging
logging_config_func(self.LOGGING)
File "/usr/lib/python2.7/logging/config.py", line 777, in dictConfig
dictConfigClass(config).configure()
File "/usr/lib/python2.7/logging/config.py", line 575, in configure
'%r: %s' % (name, e))
ValueError: Unable to configure handler 'logentries_handler': expected string or buffer
这是从 cron 运行的脚本之一 -
#!/bin/bash
echo "Loading definitions - check /var/log/supervisor/availsserver.log for results"
. /etc/profile
/home/dotcloud/env/bin/python /home/dotcloud/current/my_project/manage.py load_definitions
这些是我对 Logentries 的设置-
'logentries_handler': {
'token': os.getenv("LOGENTRIES_TOKEN"),
'class': 'logentries.LogentriesHandler'
}
....
'logentries': {
'handlers': ['logentries_handler'],
'level': 'INFO',
},
当我这样做时,LOGENTRIES_TOKEN 就在那里dotcloud env list
。
这是症状的摘要 -
- Logentries 日志记录在正常使用的站点中工作。
- 如果我手动运行脚本 -dotcloud run www ~/current/scripts/load_definitions.sh
它可以工作。
- 如果我从我settings.py
的 cron 作业中删除 Logentries 设置。
- 如果 Logentries 条目在我的settings.py
我花了几个小时试图找到解决方案。任何人都可以帮忙吗?