按照《将Airflow日志格式化为JSON》和其提到的指南,我将log_config复制到了airflow/config文件夹中。但是当我运行webserver或scheduler时,出现了“模块未定义”(init.py定义在config文件夹中)。并且PYTHONPATH被设置为airflow/config。
错误信息为:
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/airflow/logging_config.py", line 40, in configure_logging
logging_config = import_string(logging_class_path)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/airflow/utils/module_loading.py", line 33, in import_string
module = import_module(module_path)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/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 953, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'airflow.config'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/bin/airflow", line 25, in <module>
from airflow.configuration import conf
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/airflow/__init__.py", line 47, in <module>
settings.initialize()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/airflow/settings.py", line 374, in initialize
LOGGING_CLASS_PATH = configure_logging()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/airflow/logging_config.py", line 52, in configure_logging
'Unable to load custom logging from {} due to {}'.format(logging_class_path,err), isinstance('airflow',dict), isinstance('airflow.config',dict), type('airflow.config')
ImportError: ("Unable to load custom logging from airflow.config.log_config.LOGGING_CONFIG due to No module named 'airflow.config'",
现在返回以下内容:
ImportError: 由于配置中未找到 logging/logging_level 部分/键,因此无法从 airflow.config.log_config.LOGGING_CONFIG 加载自定义日志记录
。