chrisspen/django-chroniker

No entries in the log when using django logging system

Opened this issue · 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.

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

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 What did you do to work around it?

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

Ok, thanks. I'll look into this.

noisy commented

@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.