启动报错解决__init__() got an unexpected keyword argument ‘maxBytes‘ /Unable to configure handler ‘file‘

django项目部署到linux服务器后,启动报错
TypeError: init() got an unexpected keyword argument ‘maxBytes’
ValueError: Unable to configure handler ‘file’

[root@Server-faa1e742-54b1-483a-9a18-baf27781dc0c yiyan_api]# python3 manage.py runserver 0.0.0.0:8000
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/usr/local/python3/lib/python3.7/logging/config.py", line 562, in configure
    handler = self.configure_handler(handlers[name])
  File "/usr/local/python3/lib/python3.7/logging/config.py", line 735, in configure_handler
    result = factory(**kwargs)
TypeError: __init__() got an unexpected keyword argument 'maxBytes'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/python3/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/usr/local/python3/lib/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/python3/lib/python3.7/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/usr/local/python3/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 110, in inner_run
    autoreload.raise_last_exception()
  File "/usr/local/python3/lib/python3.7/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
    raise _exception[1]
  File "/usr/local/python3/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
    autoreload.check_errors(django.setup)()
  File "/usr/local/python3/lib/python3.7/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/usr/local/python3/lib/python3.7/site-packages/django/__init__.py", line 19, in setup
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
  File "/usr/local/python3/lib/python3.7/site-packages/django/utils/log.py", line 75, in configure_logging
    logging_config_func(logging_settings)
  File "/usr/local/python3/lib/python3.7/logging/config.py", line 799, in dictConfig
    dictConfigClass(config).configure()
  File "/usr/local/python3/lib/python3.7/logging/config.py", line 570, in configure
    '%r' % name) from e
ValueError: Unable to configure handler 'file'

当前django版本:3.2.13
当前logging配置

LOGGING = {
	'version': 1,
	'disable_existing_loggers': False,
	'formatters': {  # 输出格式设置
		'verbose': {
			'format': '[%(asctime)s] [%(levelname)s] %(message)s'
		},
	},
	'handlers': {
		'file': {
			'level': 'INFO',
			'class': 'logging.handlers.TimedRotatingFileHandler',
			'formatter': 'verbose',
			'encoding': 'utf-8',
			'filename': os.path.join(BASE_DIR, 'logs/yiyan.info.log'),
			'when': "D",
			'interval': 1,
		},
		'console': {
			'level': 'INFO',
			'class': 'logging.StreamHandler',
			'formatter': 'verbose',
		}
	},
	'loggers': {
		'django': {
			'handlers': ['file', 'console'],
			'level': 'INFO',
			'propagate': True  # 本记录器处理过的消息其他处理器也可以继续处理
		}
	}
}

报这个错,是因为logging配置的时候,处理器不支持maxBytes参数,拿掉参数后,再启动就好了~

你可能感兴趣的:(django,python,django,python,后端)