当 rhc tail 不显示错误时,如何在 Openshift 上调试服务器错误 500?

How to debug Server Error 500 on Openshift, when rhc tail does not show errors?

我正在尝试使用我的应用程序调试服务器错误 500。我读到您应该使用 rhc tail 来显示实时日志流,并且由于当前错误,尝试显示页面时出现的日志流是:

==> app-root/logs/python.log <==

79.24.253.62 - - [01/Jan/2015:08:32:17 -0500] "GET /url/ HTTP/1.1" 500 27 "http://a-b.rhcloud.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36"

显示的错误是:

其他页面正常,此错误仅出现在某些 "more advanced" 页面上(例如,静态页面显示正确)。日志的其余部分是:

==> app-root/logs/python.log <==

[Thu Jan 01 08:30:43 2015] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:openshift_t:s0:c6,c654

[Thu Jan 01 08:30:43 2015] [notice] Digest: generating secret for digest authentication ...

[Thu Jan 01 08:30:43 2015] [notice] Digest: done

[Thu Jan 01 08:30:43 2015] [notice] Apache/2.2.15 (Unix) mod_wsgi/3.4 Python/3.3.2 configured -- resuming normal operations

和:

==> app-root/logs/postgresql.log <==

2015-01-01 13:30:25 GMT LOG: shutting down

2015-01-01 13:30:25 GMT LOG: database system is shut down

2015-01-01 13:30:31 GMT LOG: could not bind socket for statistics collector: Permission denied

2015-01-01 13:30:31 GMT LOG: trying another address for the statistics collector

2015-01-01 13:30:31 GMT LOG: could not bind socket for statistics collector: Cannot assign requested address

2015-01-01 13:30:31 GMT LOG: disabling statistics collector for lack of working socket

2015-01-01 13:30:31 GMT WARNING: autovacuum not started because of misconfiguration

2015-01-01 13:30:31 GMT HINT: Enable the "track_counts" option.

2015-01-01 13:30:31 GMT LOG: database system was shut down at 2015-01-01 13:30:25 GMT

2015-01-01 13:30:31 GMT LOG: database system is ready to accept connections

调试此问题的下一步是什么?

我添加了以下 Django 日志记录配置,它为我提供了文件中 500 个错误的详细信息 django.log。我设置 LOG_DIR = os.environ.get('OPENSHIFT_LOG_DIR')

LOGGING = {
  'version': 1,
  'disable_existing_loggers': False,
  'handlers': {
    'file': {
      'level': 'WARNING',
      'class': 'logging.FileHandler',
      'filename': os.path.join(LOG_DIR, 'django.log'),
    },
  },
  'loggers': {
    'django.request': {
      'handlers': ['file'],
      'level': 'WARNING',
      'propagate': True,
    },
  },
}