We have recently moved to logging using ELK. We are facing issue in sending data from application to elastic search.
Our application is a .Net web application and we are sending data in json format.
We can see the log on Kibana with http details but none of the data from application is visible there.
I believe issue is with the configuration of custom field.
target name="elk" xsi:type="BufferingWrapper" flushTimeout="5000">
target xsi:type="ElasticSearch" uri="http://.swissre.com:/" includeAllProperties="true">
field name="MachineName" layout="{MachineName:raw=true}" layoutType="System.String" />
<field name="ApplicationName" layout="{event-properties:item=ApplicationName}" layoutType="System.String" />
/target>
/target>
rules>
logger name="*" minLevel="Info" writeTo="elk" enabled="true" />
/rules>
Logging is done using following method:
// Prepare the log event to prepare for logging.
var theEvent
= new LogEventInfo
(
logLevel,
this.logger.Name,
activityInfo.LogMessage // The message to log.
);
//In case there is a global execution context ID, set to the property.
if (!string.IsNullOrWhiteSpace (executionContextId))
{
activityInfo.RequestId = executionContextId;
}
var applicationName = this.swissReConfigurationSection.General.ApplicationName;
applicationName = $"{this.swissReConfigurationSection.General.ApplicationName} - {this.swissReConfigurationSection.General.EnvironmentType}";
// Add the properties of the event, which will appear as fields in the log.
// theEvent.Properties.Add(APPLICATION_NAME,applicationName);
theEvent.Properties[APPLICATION_NAME] = applicationName;
theEvent.Properties[ACTIVITY_NAME] = activityInfo.ActivityName;
theEvent.Properties[DURATION_IN_SEC] = activityInfo.DurationInSec;
theEvent.Properties[STARTED_AT] = activityInfo.StartedAt.ToLongTimeString();
theEvent.Properties[ENDED_AT] = activityInfo.EndedAt.ToLongTimeString();
theEvent.Properties[REQUEST_ID] = activityInfo.RequestId;
theEvent.Properties[USER_ID] = activityInfo.UserId;
theEvent.Properties[REQUEST_TEXT]
= String.IsNullOrEmpty(activityInfo.RequestText)
? String.Empty
: this.ReplaceCrLfWithLineFeed
(
activityInfo.RequestText
);
theEvent.Properties[RESPONSE_TEXT]
= String.IsNullOrEmpty(activityInfo.ResponseText)
? String.Empty : this.ReplaceCrLfWithLineFeed(activityInfo.ResponseText);
this.logger.Log(theEvent);