Skip to content

Commit 5080b07

Browse files
authored
Ensure correct embedded logical name for UParser.regexes.cs (#452)
1 parent 5b4004c commit 5080b07

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

examples/aspnetcore-with-serilog/appsettings.Development.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"LogLevel": {
44
"Default": "Information",
55
"Microsoft": "Warning",
6-
"Microsoft.Hosting.Lifetime": "Information"
6+
"Microsoft.Hosting.Lifetime": "Information",
7+
"Elastic.Apm": "Error"
78
}
89
}
910
}

examples/aspnetcore-with-serilog/appsettings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"LogLevel": {
44
"Default": "Information",
55
"Microsoft": "Warning",
6-
"Microsoft.Hosting.Lifetime": "Information"
6+
"Microsoft.Hosting.Lifetime": "Information",
7+
"Elastic.Apm": "Error"
78
}
89
},
910
"AllowedHosts": "*"

src/Elastic.Serilog.Enrichers.Web/Elastic.Serilog.Enrichers.Web.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
<ItemGroup>
2727
<None Remove="Lib\UAParser.regexes.yaml" />
28-
<EmbeddedResource Include="Lib\UAParser.regexes.yaml" />
28+
<EmbeddedResource Include="Lib\UAParser.regexes.yaml" LogicalName="UAParser.regexes.yaml" />
2929
</ItemGroup>
3030

3131
</Project>

src/Elastic.Serilog.Enrichers.Web/HttpContextEnricher.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,17 @@ public HttpContextEnricher(IHttpContextAccessor httpContextAccessor) =>
3838
/// <summary> Enrich the log event.</summary>
3939
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
4040
{
41-
var r = new HttpContextEnrichments();
42-
if (Adapter.HasContext)
43-
{
44-
r.Http = Adapter.Http;
45-
r.Server = Adapter.Server;
46-
r.Url = Adapter.Url;
47-
r.UserAgent = Adapter.UserAgent;
48-
r.Client = Adapter.Client;
49-
r.User = Adapter.User;
50-
}
41+
if (!Adapter.HasContext)
42+
return;
43+
44+
var r = new HttpContextEnrichments {
45+
Http = Adapter.Http,
46+
Server = Adapter.Server,
47+
Url = Adapter.Url,
48+
UserAgent = Adapter.UserAgent,
49+
Client = Adapter.Client,
50+
User = Adapter.User
51+
};
5152

5253
logEvent.AddPropertyIfAbsent(new LogEventProperty(PropertyName, new ScalarValue(r)));
5354
}

0 commit comments

Comments
 (0)