Re: [問題] Django internal error 500 debug

作者: sean72 (.)   2016-07-28 15:56:31
: → kenduest: 你沒開 log 記錄嗎 ? 07/27 08:31
: → kenduest: https://docs.djangoproject.com/en/1.9/topics/logging 07/27 08:32
: → kenduest: 開 LOGGING 之後一般語法問題等可直接可以在檔案內看到 07/27 08:32
按照doc
在setting.py裡面設定LOGGING
我可以看到python call stack traceback error了(in both console and log file)
也可以看到debug level訊息 例如sql query
但是我在view.py 裡面加入
import logging
logger = logging.getLogger(__name__)
logger.debug("debug Hey there it works!!")
logger.info("info Hey there it works!!")
logger.warn("warn Hey there it works!!")
logger.error("error Hey there it works!!")
這些訊息只會出現在console
但是並不會出現在我的log file
我找不出我的LOGGING setting哪邊有問題
麻煩大家幫我看看我下面的設定
LOGGING = {
'version': 1,
'disable_existing_loggers': False ,
'handlers': {
'file1': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': BASE_DIR + '/log/debug.log',
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
},
},
'loggers': {
'django': {
'handlers': ['file1', 'console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'DEBUG'),
'propagate': True,
},
'myproject': {
'handlers': ['file1', 'console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'DEBUG'),
'propagate': True,
},
},
}
作者: MoriUmi (森海)   2016-07-28 21:47:00
請問你有在views.py開頭寫寫入log file的程式碼嗎?你沒寫東西進去檔案當然沒東西

Links booklink

Contact Us: admin [ a t ] ucptt.com