Seldaek / monolog

Sends your logs to files, sockets, inboxes, databases and various web services
https://seldaek.github.io/monolog/
MIT License
21.02k stars 1.9k forks source link

How do I add other fields to records like user IP address or browser info while logging to Elasticsearch? #987

Closed dedipyaman closed 7 years ago

dedipyaman commented 7 years ago

I am using the ElasticsearchHandler with Elastica client to log user info to Elasticsearch. I can't seem to find a way to add more fields other than the ones automatically set by Monolog. How do I add custom fields to it?

Seldaek commented 7 years ago

According to ElasticaFormatter the Elastica\Document has setData called with the entire record, so if you add a monolog processor that adds the IP for example to the $record['extra']['ip'] = ... then it should be in there as far as I can tell.