logging level of root logger set to args.loglevel to configure from cmd line
MODIFY
rasa_sdk/__main__.py
rasa_sdk/__main__.py
@@ -6,11 +6,10 @@ from rasa_sdk.constants import APPLICATION_ROOT_LOGGER_NAME
def main_from_args(args):
- logging.basicConfig(level=logging.DEBUG)
logging.getLogger("matplotlib").setLevel(logging.WARN)
utils.configure_colored_logging(args.loglevel)
- utils.configure_file_logging(logging.getLogger(APPLICATION_ROOT_LOGGER_NAME), args.log_file)
+ utils.configure_file_logging(logging.getLogger(APPLICATION_ROOT_LOGGER_NAME), args.log_file, args.loglevel)
utils.update_sanic_log_level()
run(

MODIFY
rasa_sdk/utils.py
rasa_sdk/utils.py
@@ -94,19 +94,23 @@ def configure_colored_logging(loglevel):
)
-def configure_file_logging(logger_obj: logging.Logger, log_file: Optional[Text]) -> None:
+def configure_file_logging(logger_obj: logging.Logger, log_file: Optional[Text], loglevel: int) -> None:
"""Configure logging to a file.
Args:
- logger_obj: Logger object to configure.
- log_file: Path of log file to write to.
+ :param logger_obj: Logger object to configure.
+ :param log_file: Path of log file to write to.
+ :param loglevel:
"""
if not log_file:
return
+ if not loglevel:
+ loglevel = logging.INFO
+
formatter = logging.Formatter("%(asctime)s [%(levelname)-5.5s] %(name)s - %(message)s")
file_handler = logging.FileHandler(log_file, encoding="utf-8")
- file_handler.setLevel(logger_obj.level)
+ file_handler.setLevel(loglevel)
file_handler.setFormatter(formatter)
logger_obj.addHandler(file_handler)

logging level of root logger set to args.loglevel to configure from cmd line