elastic / ecs-logging-python

https://pypi.org/project/ecs-logging
Apache License 2.0
69 stars 25 forks source link

Flask example? #11

Open thegagne opened 4 years ago

thegagne commented 4 years ago

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

Divyadarshee commented 3 years ago

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

rdifrango commented 2 years ago

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)