django-chroniker icon indicating copy to clipboard operation
django-chroniker copied to clipboard

No entries in the log when using django logging system

Open lukaszbanasiak opened this issue 10 years ago • 6 comments

There are no entries using logger.info(), logger.debug() in the log file (https://docs.djangoproject.com/en/dev/topics/logging/) There are only entries that use print syntax.

When I use manage.py cron I get logs to stdout.

lukaszbanasiak avatar Apr 14 '14 15:04 lukaszbanasiak

Can you provide me with the specific logging configuration you have in your settings.py?

chrisspen avatar Jun 18 '14 17:06 chrisspen

Have the same issue, but worked around it, however here is my logging info:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
        },
        'simple': {
            'format': '%(levelname)s %(message)s'
        },
    },
    'handlers': {
        # Include the default Django email handler for errors
        # This is what you'd get without configuring logging at all.
        'mail_admins': {
            'class': 'django.utils.log.AdminEmailHandler',
            'level': 'ERROR',
            # But the emails are plain text by default - HTML is nicer
            'include_html': True,
        },
        # Log to a text file that can be rotated by logrotate
        'logfile': {
            'class': 'logging.handlers.WatchedFileHandler',
            'filename': BASE_DIR + "/error.log",
            'formatter': 'verbose'
        },
    },
    'loggers': {
        # Again, default Django configuration to email unhandled exceptions
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
        # Might as well log any errors anywhere else in Django
        'django': {
            'handlers': ['logfile'],
            'level': 'ERROR',
            'propagate': False,
        },
   },
}

steffenmandrup avatar Jul 09 '14 17:07 steffenmandrup

@steffenmandrup What did you do to work around it?

chrisspen avatar Jul 09 '14 19:07 chrisspen

Oh, i didn't do changes in chroniker - using a different logging system, had problems elsewhere as well so didn't bother to look into it

steffenmandrup avatar Jul 09 '14 19:07 steffenmandrup

Ok, thanks. I'll look into this.

chrisspen avatar Jul 09 '14 19:07 chrisspen

@chrisspen I have the same problem:

my configuration is:


LOGGING = {
    'version': 1,
    'root': {
        'level': 'DEBUG',
        'handlers': ['console'],
    },
    'formatters': {
        'verbose': {
            'format': '%(levelname)-8s %(asctime)s %(module)s '
                      '%(process)d %(thread)d %(message)s'
        },
        'simple': {
            '()': 'colorlog.ColoredFormatter',
            'format': '%(bold_white)s[%(asctime)s]%(log_color)s %(levelname)-8s%(reset)s %(message)s',
            'log_colors': {
                'DEBUG': 'cyan',
                'INFO': 'green',
                'WARNING': 'yellow',
                'ERROR': 'red',
                'CRITICAL': 'red,bg_white',
            },
            'datefmt': '%H:%M:%S'
        },
    },
    'handlers': {
        'console': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
            'formatter': 'simple'
        },
        'st_logfile': {
            'level': 'INFO',
            'class': 'logging.handlers.TimedRotatingFileHandler',
            'filename': LOGS_DIR("spistresci.log"),
            'when': 'd',
            'formatter': 'verbose',
            'interval': 1,
            'backupCount': 7,
        }
    },
    'loggers': {
        'spistresci': {
            'level': 'DEBUG',
            'handlers': ['console', 'st_logfile'],
            'propagate': False,
        }
    },
}

Logs appears in console, when I run python manage.py cron.

noisy avatar May 03 '16 17:05 noisy