@@ -1038,3 +1038,67 @@ of queues, for example a ZeroMQ 'subscribe' socket. Here's an example::
10381038 :ref: `A basic logging tutorial <logging-basic-tutorial >`
10391039
10401040 :ref: `A more advanced logging tutorial <logging-advanced-tutorial >`
1041+
1042+
1043+ An example dictionary-based configuration
1044+ -----------------------------------------
1045+
1046+ Below is an example of a logging configuration dictionary - it's taken from
1047+ the `documentation on the Django project <https://docs.djangoproject.com/en/1.3/topics/logging/#configuring-logging >`_.
1048+ This dictionary is passed to :func: `~logging.config.dictConfig ` to put the configuration into effect::
1049+
1050+ LOGGING = {
1051+ 'version': 1,
1052+ 'disable_existing_loggers': True,
1053+ 'formatters': {
1054+ 'verbose': {
1055+ 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
1056+ },
1057+ 'simple': {
1058+ 'format': '%(levelname)s %(message)s'
1059+ },
1060+ },
1061+ 'filters': {
1062+ 'special': {
1063+ '()': 'project.logging.SpecialFilter',
1064+ 'foo': 'bar',
1065+ }
1066+ },
1067+ 'handlers': {
1068+ 'null': {
1069+ 'level':'DEBUG',
1070+ 'class':'django.utils.log.NullHandler',
1071+ },
1072+ 'console':{
1073+ 'level':'DEBUG',
1074+ 'class':'logging.StreamHandler',
1075+ 'formatter': 'simple'
1076+ },
1077+ 'mail_admins': {
1078+ 'level': 'ERROR',
1079+ 'class': 'django.utils.log.AdminEmailHandler',
1080+ 'filters': ['special']
1081+ }
1082+ },
1083+ 'loggers': {
1084+ 'django': {
1085+ 'handlers':['null'],
1086+ 'propagate': True,
1087+ 'level':'INFO',
1088+ },
1089+ 'django.request': {
1090+ 'handlers': ['mail_admins'],
1091+ 'level': 'ERROR',
1092+ 'propagate': False,
1093+ },
1094+ 'myproject.custom': {
1095+ 'handlers': ['console', 'mail_admins'],
1096+ 'level': 'INFO',
1097+ 'filters': ['special']
1098+ }
1099+ }
1100+ }
1101+
1102+ For more information about this configuration, you can see the `relevant
1103+ section <https://docs.djangoproject.com/en/1.3/topics/logging/#configuring-logging> `_
1104+ of the Django documentation.
0 commit comments