Using NLog, when I log object/"structured data" to Elastic Search it stored in away that I can not make query on it, Please look to below image:
<target xsi:type="ElasticSearch" name="MyElasticTarget" uri="url" requireAuth="true" username="MyUser" password="MyPass" Index="MyIndex-${date:format=yyyy.MM.dd}" > <layout xsi:type="JsonLayout" type='JsonLayout' IncludeAllProperties='true'> <attribute name='LogMessage' layout='${MySimpleClass:raw=true}' /> </layout> </target> </targets>
And the code is:
var _simpleObj = new MySimpleClass(5, "my structured Simple obj", "Sometype"); var logger = LogManager.GetLogger("Example"); logger.Info("{@MySimpleClass}", _simpleObj );
While When I log/store the same Structured data by using SeriLog, I can do query because I have the fields of object out of the message scope and as fields, please look to below image:
Any Idea how I can log structured data (objects) in be able to query them by use NLog?