Breaking new relic format on a new line character in FileHandler appender

Chris Angelico rosuav at gmail.com
Thu Nov 11 01:19:42 EST 2021


On Thu, Nov 11, 2021 at 5:00 PM Vijay Karavadra via Python-list
<python-list at python.org> wrote:
>
> Hello Team,
>
> I'm trying to add logs in the new relic platform from a python application.
> For that, I've to add logs in a local file in a specific format which is
>
> '{"log.level":"%(levelname)s", "log.entity.name":"my-service-name",
> "message":"%(message)s"}'
>

Looks like JSON to me. Have you considered using the json module to format it?

json.dumps({"log.level":levelname, "log.entity.name":"my-service-name",
"message":message})

ChrisA


More information about the Python-list mailing list