Logging in Json

Is there any way I can rewrite all the logs in Rasa into Json format?

I foung out that I can use python-json-logger library and add JsonFormatter to the logger, for example here rasa/action.py at main · RasaHQ/rasa (github.com) like this:

logger = logging.getLogger(__name__)

from pythonjsonlogger import jsonlogger

logHandler = logging.StreamHandler()

formatter = jsonlogger.JsonFormatter("%(asctime)s %(levelname)s %(name)s %(message)s",json_ensure_ascii=False)

But if I do this, I get doubled logs (in json and not in json):

{"asctime": "2021-11-08 15:54:16,075", "levelname": "DEBUG", "name": "rasa.core.actions.action", "message": "Calling action en
dpoint to run action 'action_balance-parameters_get-credit-limit'."}
2021-11-08 15:54:16,075 - rasa.core.actions.action - DEBUG - Calling action endpoint to run action 'action_balance-parameters_get-c

How can I get rid of the doubling?

Try adding the --quiet flag:

rasa run actions --quiet

Reference: Command Line Interface

Thank you, that helped! :grinning_face_with_smiling_eyes:

1 Like