Skip to content

Commit

Permalink
Ensure correct embedded logical name for UParser.regexes.cs (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mpdreamz authored Oct 3, 2024
1 parent 5b4004c commit 5080b07
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
"Microsoft.Hosting.Lifetime": "Information",
"Elastic.Apm": "Error"
}
}
}
3 changes: 2 additions & 1 deletion examples/aspnetcore-with-serilog/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
"Microsoft.Hosting.Lifetime": "Information",
"Elastic.Apm": "Error"
}
},
"AllowedHosts": "*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<ItemGroup>
<None Remove="Lib\UAParser.regexes.yaml" />
<EmbeddedResource Include="Lib\UAParser.regexes.yaml" />
<EmbeddedResource Include="Lib\UAParser.regexes.yaml" LogicalName="UAParser.regexes.yaml" />
</ItemGroup>

</Project>
21 changes: 11 additions & 10 deletions src/Elastic.Serilog.Enrichers.Web/HttpContextEnricher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,17 @@ public HttpContextEnricher(IHttpContextAccessor httpContextAccessor) =>
/// <summary> Enrich the log event.</summary>
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
{
var r = new HttpContextEnrichments();
if (Adapter.HasContext)
{
r.Http = Adapter.Http;
r.Server = Adapter.Server;
r.Url = Adapter.Url;
r.UserAgent = Adapter.UserAgent;
r.Client = Adapter.Client;
r.User = Adapter.User;
}
if (!Adapter.HasContext)
return;

var r = new HttpContextEnrichments {
Http = Adapter.Http,
Server = Adapter.Server,
Url = Adapter.Url,
UserAgent = Adapter.UserAgent,
Client = Adapter.Client,
User = Adapter.User
};

logEvent.AddPropertyIfAbsent(new LogEventProperty(PropertyName, new ScalarValue(r)));
}
Expand Down

0 comments on commit 5080b07

Please sign in to comment.