Closed EddLonzanida closed 3 years ago
Sample configuration:
{
"NLog": {
"autoReload": false,
"throwConfigExceptions": false,
"internalLogLevel": "Error",
"extensions": [
{ "assembly": "NLog.Targets.ElasticSearch" },
{ "assembly": "NLog.Web.AspNetCore" }
],
"default-wrapper": {
"type": "AsyncWrapper",
"overflowAction": "Discard"
},
"targets": {
"Elastic": {
"type": "BufferingWrapper",
"flushTimeout": "5000",
"target": {
"type": "ElasticSearch",
"cloudId": "${gdc:item=cloudId}", //<-If cloudId, apiKey and apiKeyId is provided, ApiKeyAuthenticationCredentials will be used, otherwise, BasicAuthenticationCredentials is used
"apiKeyId": "${gdc:item=apiKeyId}", //<-If cloudId, apiKey and apiKeyId is provided, ApiKeyAuthenticationCredentials will be used, otherwise, BasicAuthenticationCredentials is used
"apiKey": "${gdc:item=apiKey}", //<-If cloudId, apiKey and apiKeyId is provided, ApiKeyAuthenticationCredentials will be used, otherwise, BasicAuthenticationCredentials is used
"index": "applogs-dev",
"includeAllProperties": false,
"includeDefaultFields": false, //<-set to false if you need to explicitly specify custom fields
"maxRecursionLimit ": 1,
"fields": [ //<-explicitly specify custom fields here
{
"name": "source",
"layout": "test.service"
},
{
"name": "@timestamp",
"layout": "${date:universalTime=True:format=o}"
},
{
"name": "clientTimeStamp",
"layout": "${date:format=o}"
},
{
"name": "level",
"layout": "${level}"
},
{
"name": "releaseVersion",
"layout": "${gdc:releaseVersion}"
},
{
"name": "additionalInfo",
"layout": "Environment:'${gdc:item=env}'${newline}${event-properties:additionalInfo}"
},
{
"name": "callSite",
"layout": "${callSite}"
},
{
"name": "machineName",
"layout": "${machineName}"
},
{
"name": "message",
"layout": "${when:when='${exception:format=message}'=='':inner=${message}:else=${exception:format=message}}"
},
{
"name": "stackTrace",
"layout": "${exception:format=stackTrace}"
},
{
"name": "innerException",
"layout": "${exception:format=:innerFormat=ShortType,Message,Method:MaxInnerExceptionLevel=1:InnerExceptionSeparator=}"
},
{
"name": "type",
"layout": "${exception:format=type}"
}
]
}
}
},
"rules": [
{
"logger": "*",
"minLevel": "Debug",
"writeTo": "Elastic"
}
]
}
}
Thank you. Do you have plan on merging this to master anytime soon?
I guess it will be merged when @markmcdowell has time to review, and approves of the changes.
Thank you @markmcdowell . Please release the NuGet soon so i can use it in my projects.
Wiki has been updated to reflect these new parameters.
Checklist