老师我在settings中添加日志为什么启动不起来? 删除就可以启动了
来源:7-2 新建项目和apps
慕粉9239277
2020-03-28
# 日志配置
LOGGING = {
'version': 1,
'disable_existing_loggers': False, # 是否禁用其他日志
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(lineno)d %(message)s'
},
'simple': {
'format': '%(levelname)s %(module)s %(lineno)d %(message)s'
},
},
# 日志过滤
'filters': {
'require_debug_true': {
'()': 'django.utils.log.RequireDebugTrue',
},
},
# 日志操作方式
'handlers': {
'console': {
'level': 'DEBUG',
'filters': ['require_debug_true'],
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
'file': {
'level': 'INFO',
'class': 'logging.handlers.RotatingFileHandler',
# 日志输出位置,日志文件名,日志保存目录必须手动创建
'filename': os.path.join(os.path.dirname(BASE_DIR), "logs/MxOnline.log"),
# 日志文件最大值,300M
'maxBytes': 300 * 1024 * 1024,
# 日志文件的数量,设置最大日志数量为10
'backupCount': 10,
#日志格式:详细格式
'formatter': 'verbose'
},
},
# 日志对象
'loggers': {
'MxOnline': {
'handlers': ['console', 'file'],
'propagate': True, # 是否让日志信息继续冒泡给其他日志处理系统
},
}
}
Traceback (most recent call last):
File "E:/virtual_environment/mypython/MxOnline/manage.py", line 21, in <module>
main()
File "E:/virtual_environment/mypython/MxOnline/manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "E:\virtual_environment\Python3.7.3\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "E:\virtual_environment\Python3.7.3\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "E:\virtual_environment\Python3.7.3\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "E:\virtual_environment\Python3.7.3\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "E:\virtual_environment\Python3.7.3\lib\site-packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, **options)
File "E:\virtual_environment\Python3.7.3\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle
self.run(**options)
File "E:\virtual_environment\Python3.7.3\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "E:\virtual_environment\Python3.7.3\lib\site-packages\django\utils\autoreload.py", line 579, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "E:\virtual_environment\Python3.7.3\lib\site-packages\django\utils\autoreload.py", line 564, in start_django
reloader.run(django_main_thread)
File "E:\virtual_environment\Python3.7.3\lib\site-packages\django\utils\autoreload.py", line 272, in run
get_resolver().urlconf_module
File "E:\virtual_environment\Python3.7.3\lib\site-packages\django\utils\functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "E:\virtual_environment\Python3.7.3\lib\site-packages\django\urls\resolvers.py", line 564, in urlconf_module
return import_module(self.urlconf_name)
File "E:\virtual_environment\Python3.7.3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "E:\virtual_environment\mypython\MxOnline\MxOnline\urls.py", line 20, in <module>
path('admin/', admin.site.urls),
File "E:\virtual_environment\Python3.7.3\lib\site-packages\django\utils\functional.py", line 256, in inner
self._setup()
File "E:\virtual_environment\Python3.7.3\lib\site-packages\django\contrib\admin\sites.py", line 529, in _setup
AdminSiteClass = import_string(apps.get_app_config('admin').default_site)
File "E:\virtual_environment\Python3.7.3\lib\site-packages\django\apps\registry.py", line 162, in get_app_config
raise LookupError(message)
LookupError: No installed app with label 'admin'.
写回答
1回答
-
囧神1808
2020-03-29
你的installed_app里有没有加django.atribute.admin? 请注意看日志。
052020-04-02
相似问题