markmcdowell/NLog.Targets.ElasticSearch

How to identify logs come from which container?

xclw2000 opened this issue · 1 comments

When my app running on docker, there will be many containers write log to elastic. I hope each log contains it's container information(IP address or k8s pod name and so on), so I can identify this log comes from which container. How to achieve it?

You can specify additional fields like this:

<target xsi:type="ElasticSearch" uri="http://localhost:9200/" >
     <field name="logger" layout="${logger}" />
     <field name="hostName" layout="${hostname}" />
</target>

You can also inject container-details into NLog GDC, and then use <field name="container" layout="${gdc:item=ContainerInfo}" />