1

my logging is not working on the dev server, instead locally is working. here is the configuration:

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 %(asctime)s %(message)s'
        },
    },
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse',
        },
        'require_debug_true': {
            '()': 'django.utils.log.RequireDebugTrue',
        },
    },
    'handlers': {
        'log_file':{
            'level': 'INFO',
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': '/var/log/django/my_project.log',
            'maxBytes': '16777216', # 16 MB
            'formatter': 'simple'
        },
        'console': {
            'level': 'DEBUG',
            'filters': ['require_debug_true'],
            'class': 'logging.StreamHandler',
            'formatter': 'simple'
        },
        'null': {
            'class': 'logging.NullHandler',
        },
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        }
    },
    'loggers': {
        'my_project': {
            'handlers': ['log_file', 'console'],
            'level': 'INFO',
            'propagate': True,
        },
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': False,
        },
    }
}

then, if I create a logger instance:

logger = logging.getLogger('my_project')

and I try to log something:

logger.info('something')
logger.debug('something else')

it doesn't work (nothing written on /var/log/django/my_project.log), while locally it works. Am I missing something?

Luke
  • 1,794
  • 10
  • 43
  • 70

1 Answers1

1

Maybe a write permission missing? Is the user with which you run the App allowed to write in /var?

Yom86
  • 196
  • 1
  • 6