Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
a014ddfe
Kaydet (Commit)
a014ddfe
authored
Eyl 24, 2012
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Combined Django DEFAULT_LOGGING with user LOGGING config
Refs #18993.
üst
15202baa
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
37 deletions
+65
-37
__init__.py
django/conf/__init__.py
+8
-4
global_settings.py
django/conf/global_settings.py
+2
-27
log.py
django/utils/log.py
+33
-6
logging.txt
docs/topics/logging.txt
+22
-0
No files found.
django/conf/__init__.py
Dosyayı görüntüle @
a014ddfe
...
...
@@ -55,16 +55,20 @@ class LazySettings(LazyObject):
Setup logging from LOGGING_CONFIG and LOGGING settings.
"""
if
self
.
LOGGING_CONFIG
:
from
django.utils.log
import
DEFAULT_LOGGING
# First find the logging configuration function ...
logging_config_path
,
logging_config_func_name
=
self
.
LOGGING_CONFIG
.
rsplit
(
'.'
,
1
)
logging_config_module
=
importlib
.
import_module
(
logging_config_path
)
logging_config_func
=
getattr
(
logging_config_module
,
logging_config_func_name
)
# Backwards-compatibility shim for #16288 fix
compat_patch_logging_config
(
self
.
LOGGING
)
logging_config_func
(
DEFAULT_LOGGING
)
# ... then invoke it with the logging settings
logging_config_func
(
self
.
LOGGING
)
if
self
.
LOGGING
:
# Backwards-compatibility shim for #16288 fix
compat_patch_logging_config
(
self
.
LOGGING
)
# ... then invoke it with the logging settings
logging_config_func
(
self
.
LOGGING
)
def
configure
(
self
,
default_settings
=
global_settings
,
**
options
):
"""
...
...
django/conf/global_settings.py
Dosyayı görüntüle @
a014ddfe
...
...
@@ -551,33 +551,8 @@ MESSAGE_STORAGE = 'django.contrib.messages.storage.fallback.FallbackStorage'
# The callable to use to configure logging
LOGGING_CONFIG
=
'django.utils.log.dictConfig'
# The default logging configuration. This sends an email to
# the site admins on every HTTP 500 error. All other log
# records are sent to the bit bucket.
LOGGING
=
{
'version'
:
1
,
'disable_existing_loggers'
:
False
,
'filters'
:
{
'require_debug_false'
:
{
'()'
:
'django.utils.log.RequireDebugFalse'
,
}
},
'handlers'
:
{
'mail_admins'
:
{
'level'
:
'ERROR'
,
'filters'
:
[
'require_debug_false'
],
'class'
:
'django.utils.log.AdminEmailHandler'
}
},
'loggers'
:
{
'django.request'
:
{
'handlers'
:
[
'mail_admins'
],
'level'
:
'ERROR'
,
'propagate'
:
True
,
},
}
}
# Custom logging configuration.
LOGGING
=
{}
# Default exception reporter filter class used in case none has been
# specifically assigned to the HttpRequest instance.
...
...
django/utils/log.py
Dosyayı görüntüle @
a014ddfe
...
...
@@ -5,6 +5,7 @@ from django.conf import settings
from
django.core
import
mail
from
django.views.debug
import
ExceptionReporter
,
get_exception_reporter_filter
# Make sure a NullHandler is available
# This was added in Python 2.7/3.2
try
:
...
...
@@ -23,12 +24,38 @@ except ImportError:
getLogger
=
logging
.
getLogger
# Ensure the creation of the Django logger
# with a null handler. This ensures we don't get any
# 'No handlers could be found for logger "django"' messages
logger
=
getLogger
(
'django'
)
if
not
logger
.
handlers
:
logger
.
addHandler
(
NullHandler
())
# Default logging for Django. This sends an email to
# the site admins on every HTTP 500 error. All other log
# records are sent to the bit bucket.
DEFAULT_LOGGING
=
{
'version'
:
1
,
'disable_existing_loggers'
:
False
,
'filters'
:
{
'require_debug_false'
:
{
'()'
:
'django.utils.log.RequireDebugFalse'
,
}
},
'handlers'
:
{
'null'
:
{
'class'
:
'django.utils.log.NullHandler'
,
},
'mail_admins'
:
{
'level'
:
'ERROR'
,
'filters'
:
[
'require_debug_false'
],
'class'
:
'django.utils.log.AdminEmailHandler'
}
},
'loggers'
:
{
'django'
:
{
'handlers'
:
[
'null'
],
},
'django.request'
:
{
'handlers'
:
[
'mail_admins'
],
'level'
:
'ERROR'
,
'propagate'
:
True
,
},
}
}
class
AdminEmailHandler
(
logging
.
Handler
):
...
...
docs/topics/logging.txt
Dosyayı görüntüle @
a014ddfe
...
...
@@ -192,6 +192,8 @@ There are two other logging calls available:
* ``logger.exception()``: Creates an ``ERROR`` level logging
message wrapping the current exception stack frame.
.. _configuring-logging:
Configuring logging
===================
...
...
@@ -216,6 +218,14 @@ handlers, filters and formatters that you want in your logging setup,
and the log levels and other properties that you want those components
to have.
Prior to Django 1.5, the :setting:`LOGGING` setting overwrote the :ref:`default
Django logging configuration <default-logging-configuration>`. From Django
1.5 forward, the project's logging configuration is merged with Django's
defaults, hence you can decide if you want to add to, or replace the existing
configuration. To completely override the default configuration, set the
``disable_existing_loggers`` key to True in the :setting:`LOGGING`
dictConfig. Alternatively you can redefine some or all of the loggers.
Logging is configured as soon as settings have been loaded
(either manually using :func:`~django.conf.settings.configure` or when at least
one setting is accessed). Since the loading of settings is one of the first
...
...
@@ -535,3 +545,15 @@ logging module.
'class': 'django.utils.log.AdminEmailHandler'
}
},
.. _default-logging-configuration:
Django's default logging configuration
======================================
By default, Django configures the ``django.request`` logger so that all messages
with ``ERROR`` or ``CRITICAL`` level are sent to :class:`AdminEmailHandler`, as
long as the :setting:`DEBUG` setting is set to ``False``.
All messages reaching the ``django`` catch-all logger are discarded
(sent to ``NullHandler``).
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment