Closed pccai closed 1 year ago
Hello,
We don't actively use NLog in our applications (outside of samples) anymore so please let me know what I'm missing as it's been a while.
In the nighly builds I've upgraded us to NLog 5.1. What is this doing with the UserIdentity
field? We have LogEventBuilder
extensions for identity and we have this in our sample configuration but I don't see anywhere where that is setting the identity on the event:
<target xsi:type="Exceptionless, Exceptionless.NLog" name="exceptionless" apiKey="API_KEY_HERE">
<field name="host" layout="${machinename}" />
<field name="identity" layout="${identity}" />
<field name="windows-identity" layout="${windows-identity:userName=True:domain=False}" />
<field name="process" layout="${processname}" />
</target>
Are you expecting us to pick up specific fields and to set the identity from that? I'm not entirely sure a target can get access to rendered fields, it would be a massive help if you could debug this and work with us on this.
Looks like it may be possible we may just have to look at and handle it here:
var builder = _client.CreateFromLogEvent(logEvent);
foreach (var field in Fields) {
var renderedField = field.Layout.Render(logEvent);
if (!String.IsNullOrWhiteSpace(renderedField))
builder.AddObject(renderedField, field.Name);
}
Created #299 that adds support for doing this:
<target type="Exceptionless, Exceptionless.NLog" name="exceptionless" apiKey="API_KEY_HERE" userIdentity="${aspnet-user-identity}">
<field name="host" layout="${machinename}" />
<field name="process" layout="${processname}" />
</target>
See also: https://nlog-project.org/config/?tab=layout-renderers
Awesome Thanks!, I've left some comments on #299
Aspnet Web user cannot configured by NLog.config and write to el? like this:
<field name="UserIdentity" layout="${user}"/>