Still get the same error message

vineeth sagar <[email protected]> 于2019年6月11日周二 上午2:08写道:

> Try this with the override_settings decorator. like this.
>
> @override_settings(LOGGING_DIR='/tmp/test_logs/'
> def test_function1(self):
>     pass
>
> On Mon, Jun 10, 2019 at 7:15 PM panfei <[email protected]> wrote:
>
>> 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
>> <https://groups.google.com/d/msgid/django-users/CA%2BJstLD7nDPz_%2BCs203Eh2Qzk-A1wawOzbtA%3DpFE7Lb0FZBaeQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> 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/CAMMZq8NDG_WFJXofeBub7oMysWKFDWo%3DUUC23r0NdM0DC3UV1w%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAMMZq8NDG_WFJXofeBub7oMysWKFDWo%3DUUC23r0NdM0DC3UV1w%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
不学习,不知道

-- 
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%2BJstLCkXm6-fy5fQgHr8XhXubMMk9qj2ODVfXtzsEzVpCSD6A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to