There is a logger path for production environment, but I want to put the
logs in /tmp/ in unittests.

This is the LOGGING settings for production environment:

LOGGING_DIR = '/data0/bridge_logs_test/'
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'default': {
            'format':
'{levelname}\t{asctime}\t{pathname}\t{lineno:d}\t{process:d}\t{message}',
            'style': '{'
        }
    },

    'handlers': {
        'console_log_handler': {
            'level': 'ERROR',
            'class': 'logging.StreamHandler',
        },

'backup_log_handler': {
    'level': 'INFO',
    'class': 'logging.handlers.WatchedFileHandler',
    'filename': os.path.join(LOGGING_DIR, 'put.log'),
    'formatter': 'default',
},

        ......
    },

    'loggers': {
        'django': {
            'handlers': ['console_log_handler', ],
            'level': 'DEBUG',
            'propagate': True,
        },

'backup': {
    'handlers': ['backup_log_handler', ],
    'level': 'INFO',
    'propagate': False,
},

        ......
    },
}

And in unittests, I write:

from django.test import TestCase
class FaceAITestCase(TestCase):
    def test_function1(self):
        with self.modify_settings(LOGGING_DIR="/tmp/test_logs/"):
            pass


When run the unittests, it reports:
ValueError: Unable to configure handler 'access_log_handler': [Errno
2] No such file or directory: '/data0/bridge_logs_test/access.log'

And how to use /tmp/test_logs/ as the log directory in unittests ? any
ideas ? Thanks.
-- 
不学习,不知道

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/CA%2BJstLD7nDPz_%2BCs203Eh2Qzk-A1wawOzbtA%3DpFE7Lb0FZBaeQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to