Thursday, July 26, 2018

Re: How to see every activity in logs of Django 2.0.6?

I tried with below one to include warning also but no any warning or error in logs-
LOGGING_CONFIG = None

LOGLEVEL = os.environ.get('LOGLEVEL', 'info').upper()

logging
.config.dictConfig({
   
'version': 1,
   
'disable_existing_loggers': False,
   
'formatters': {
       
'default': {
           
# exact format is not important, this is the minimum information
            'format': '%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
       
},
       
'django.server': DEFAULT_LOGGING['formatters']['django.server'],
   
},
   
'handlers': {
       
# console logs to stderr
        'console': {
           
'class': 'logging.StreamHandler',
           
'formatter': 'default',
       
},
       
# Add Handler for Sentry for `warning` and above
        'sentry': {
           
'level': 'WARNING',
           
'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler',
       
},
       
'django.server': DEFAULT_LOGGING['handlers']['django.server'],
   
},
   
'loggers': {
       
# default for all undefined Python modules
        '': {
           
'level': 'WARNING',
           
'handlers': ['console', 'sentry'],
       
},
       
# Our application code
        'app': {
           
'level': LOGLEVEL,
           
'handlers': ['console', 'sentry'],
           
# Avoid double logging because of root logger
            'propagate': False,
       
},
       
# Prevent noisy modules from logging to Sentry
        'noisy_module': {
           
'level': 'ERROR',
           
'handlers': ['console'],
           
'propagate': False,
       
},
       
# Default runserver request logging
        'django.server': DEFAULT_LOGGING['loggers']['django.server'],
   
},
})



On Thursday, July 26, 2018 at 6:06:16 PM UTC+5:30, Jason wrote:
OK, that's helpful.  Your loggers are set to handle error and above, right?  So Django's blocked from doing any logging below that, even with DEBUG = True

On Thursday, July 26, 2018 at 7:46:19 AM UTC-4, prateek gupta wrote:
I forgot to mentions, I am using logger also as below-
# send server errors to admin
ADMINS = (('admin', 'admin@example.com'),)
MANAGERS
= ADMINS

# Logging configuration for production
LOGGING = {
   
'version': 1,
   
'disable_existing_loggers': False,
   
'formatters': {
       
'verbose': {
           
'format': '%(asctime)s [%(levelname)s] %(filename)s:%(lineno)s %(funcName)s() : %(message)s'
        },
       
'simple': {
           
'format': '%(asctime)s [%(levelname)s] : %(message)s'
        },
   
},
   
'handlers': {
       
'file': {
           
'level': 'ERROR',
           
'class': 'logging.FileHandler',
           
'filename': 'error.log',
           
'formatter': 'verbose'
        },
       
'mail_admins': {
           
'level': 'ERROR',
           
'class': 'django.utils.log.AdminEmailHandler',
           
'formatter': 'simple'
        },
   
},
   
'loggers': {
       
'django': {
           
'handlers': ['file'],
           
'level': 'ERROR',
           
'propagate': True,
       
},
       
'django.request': {
           
'handlers': ['mail_admins'],
           
'level': 'ERROR',
           
'propagate': True,
       
},
   
},
}



On Thursday, July 26, 2018 at 4:47:18 PM UTC+5:30, Jason wrote:
ok, so you don't even have any logging configuration at all, no wonder you don't see anything.

I suggest you look in the docs for this:  https://docs.djangoproject.com/en/2.0/topics/logging/


--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ff6f8a29-0bcb-4cbe-a42f-15b6d424d366%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment