# How can i control the structure of Elastic.CommonSchema.NLog

**URL:** <https://discuss.elastic.co/t/how-can-i-control-the-structure-of-elastic-commonschema-nlog/370411>\
**Category:** Elasticsearch\
**Created:** [November 12, 2024, 2:50pm UTC](https://discuss.elastic.co/t/how-can-i-control-the-structure-of-elastic-commonschema-nlog/370411 "2024-11-12T14:50:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Habib\_Khan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/habib_khan/32/138000_2.png) [@Habib\_Khan](https://discuss.elastic.co/u/Habib_Khan)\
**Post date:** [November 12, 2024, 2:50pm UTC](https://discuss.elastic.co/t/how-can-i-control-the-structure-of-elastic-commonschema-nlog/370411/1 "2024-11-12T14:50:05Z")

</div>

I have follow xml file

```auto
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      autoReload="true"
      internalLogLevel="Debug"
      internalLogFile="c:\work\log-internal.txt">
 
	<!-- Load the necessary NLog extensions -->
<extensions>
<add assembly="Elastic.NLog.Targets" />
<add assembly="Elastic.CommonSchema.NLog" />
</extensions>
 
	<targets>
<!-- Define the Elasticsearch target -->
<target xsi:type="ElasticSearch"
				name="elastic"
			nodeUris=""
			username="elastic"                       
			password="">           
 
			<!-- Define the index format -->
<indexFormat>testing</indexFormat>
 
			<!-- Define a custom JsonLayout to include only specific fields -->
<layout xsi:type="EcsLayout" IncludeEventProperties="true"
               excludeProperties="url.domain,url.path">

</layout>
</target>
</targets>
 
	<rules>
<!-- Define logging rules -->
<!-- This rule logs only 'Error' level logs from the specified logger to Elasticsearch -->
<logger name="ElasticsearchLoging.Controllers.HomeController"
				minLevel="Error"
				maxLevel="Error"
				writeTo="elastic" />
</rules>
</nlog>

```

I am using the lastest elastic library "Elastic.NLog.Targets" and "Elastic.CommonSchema.NLog" for saving the logs on elasticsearch and it is working fine  
output:  
{  
"@timestamp": "2020-02-20T16:07:06.7109766+11:00",  
"log.level": "Info",  
"message": "Info "X" 2.2",  
"ecs.version": "8.6.0",  
"log": {  
"logger": "Elastic.CommonSchema.NLog.Tests.LogTestsBase"  
},  
"labels": {  
"ValueX": "X"  
},  
"agent": {  
"type": "Elastic.CommonSchema.NLog",  
"version": "1.6.0"  
},  
"event": {  
"created": "2020-02-20T16:07:06.7109766+11:00",  
"severity": 6,  
"timezone": "Romance Standard Time"  
},  
"host": {  
"ip": ["127.0.0.1"],  
"name": "LOCALHOST"  
},  
"process": {  
"executable": "C:\Program Files\dotnet\dotnet.exe",  
"name": "dotnet",  
"pid": 17592,  
"thread.id": 17592,  
"title": "15.0.0.0"  
},  
"server": { "user": { "name": "MyUser" } },  
"service": {  
"name": "Elastic.CommonSchema",  
"type": "dotnet",  
"version": "1.6.0"  
},  
"metadata": {  
"SomeY": 2.2  
},  
"MessageTemplate": "Info {ValueX} {SomeY} {NotX}"  
}  
this is how the logs are getting store in elasticsearch. But i want to store specific fields on elastisearch like this

> {  
> "@timestamp": "2020-02-20T16:07:06.7109766+11:00",  
> "log.level": "Info",  
> "message": "Info "X" 2.2",  
> "ecs.version": "8.6.0",  
> }  
> if anyone know about how can i control the structure with those above libraries kindly share here.
