On 4/12/2019 4:19 pm, Charles Jason Decena wrote:
is there a way to retrieve the handler 500 data/error? and also can i
have multiple handler 500 in my base url in order to be dynamic? and
how to get the error message in handler500
Not sure I understand exactly what you are asking for but this is
straight from the docs except where I set up my path to my log file. My
WEB_ROOT is /var/www and PROJECT is myproject
HTH
Mike
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
import os
logpath = os.path.join(WEB_ROOT, "log", PROJECT)
if not os.path.isdir(logpath):
os.makedirs(logpath)
logfile = os.path.join(logpath, "django.log")
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
# # # # # # # # # # #
"handlers": {
"file": {
"level": "DEBUG",
"class": "logging.FileHandler",
"formatter": "default",
"encoding": "utf_8",
"filename": logfile,
},
"console": {
"level": "DEBUG",
"class": "logging.StreamHandler",
"filters": ["require_debug_true"],
"formatter": "simple",
},
"mail_admins": {
"level": "ERROR",
"filters": ["require_debug_false"],
"class": "django.utils.log.AdminEmailHandler",
"include_html": True,
},
},
# # # # # # # # # # #
"loggers": {
# ensure that all log entries are propagated to root
"myproject": {"propagate": True},
"myproject.info": {
"handlers": ["console", "mail_admins"],
"level": "INFO",
"propagate": True,
},
"django": {"propagate": True},
"django.request": {
"handlers": ["mail_admins"],
"level": "ERROR",
"propagate": True,
},
"django.template": {"handlers": ["console"]},
"django.security": {"propagate": True},
"py.warnings": {"propagate": True},
},
# # # # # # # # # # #
"root": {"handlers": ["file"], "level": "DEBUG"},
# # # # # # # # # # #
"formatters": {
"default": {
"format": "%(levelname)s %(pathname)s TIME: %(asctime)s MSG:
%(filename)s:%(funcName)s:%(lineno)d %(message)s"
},
"simple": {"format": "%(funcName)s:%(lineno)d %(message)s"},
},
# # # # # # # # # # #
"filters": {
"require_debug_false": {"()": "django.utils.log.RequireDebugFalse"},
"require_debug_true": {"()": "django.utils.log.RequireDebugTrue"},
},
# # # # # # # # # # #
}
--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/c65b91c2-dbea-4113-a446-6a4892f08135%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/c65b91c2-dbea-4113-a446-6a4892f08135%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/dd4985a4-e9b9-e7cf-d33a-114ff7c5bf7f%40dewhirst.com.au.