ecs-logging-python icon indicating copy to clipboard operation
ecs-logging-python copied to clipboard

Flask example?

Open thegagne opened this issue 5 years ago • 2 comments

It would be great to have an example that works with flask.

thegagne avatar Jul 04 '20 19:07 thegagne

@thegagne did you get a chance to successfully use this for the flask framework?

Divyadarshee avatar Jul 09 '21 04:07 Divyadarshee

Here's how I integrated it into Flask, it's simply adding the handler to app.logger which Flask exposes:

# Add an ECS formatter to the Handler
handler = logging.StreamHandler()
handler.setFormatter(ecs_logging.StdlibFormatter())
app.logger.addHandler(handler)

rdifrango avatar Oct 05 '21 15:10 rdifrango