-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce Elastic.Serilog.Enrichers.Web (#444)
Fixes: #343 --------- Co-authored-by: Steve Gordon <[email protected]>
- Loading branch information
1 parent
6f15e7c
commit 4108bf9
Showing
18 changed files
with
144 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
namespace Elastic.CommonSchema.Serilog; | ||
|
||
/// <summary> Defines known keys and types to read from serilog properties </summary> | ||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member | ||
public static class SpecialProperties | ||
{ | ||
public class HttpContextEnrichments | ||
{ | ||
public Client? Client { get; set; } | ||
public Http? Http { get; set; } | ||
public Server? Server { get; set; } | ||
public Url? Url { get; set; } | ||
public User? User { get; set; } | ||
public UserAgent? UserAgent { get; set; } | ||
} | ||
|
||
public static class SpecialKeys | ||
{ | ||
public const string DefaultLogger = "Elastic.CommonSchema.Serilog"; | ||
|
||
public const string SourceContext = nameof(SourceContext); | ||
public const string EnvironmentUserName = nameof(EnvironmentUserName); | ||
public const string Host = nameof(Host); | ||
public const string ActionCategory = nameof(ActionCategory); | ||
public const string ActionName = nameof(ActionName); | ||
public const string ActionId = nameof(ActionId); | ||
public const string ActionKind = nameof(ActionKind); | ||
public const string ActionSeverity = nameof(ActionSeverity); | ||
public const string EventId = nameof(EventId); | ||
public const string ApplicationId = nameof(ApplicationId); | ||
public const string ApplicationName = nameof(ApplicationName); | ||
public const string ApplicationType = nameof(ApplicationType); | ||
public const string ApplicationVersion = nameof(ApplicationVersion); | ||
public const string ProcessName = nameof(ProcessName); | ||
public const string ProcessId = nameof(ProcessId); | ||
public const string ThreadId = nameof(ThreadId); | ||
public const string MachineName = nameof(MachineName); | ||
public const string Elapsed = nameof(Elapsed); | ||
public const string ElapsedMilliseconds = nameof(ElapsedMilliseconds); | ||
public const string Method = nameof(Method); | ||
public const string RequestMethod = nameof(RequestMethod); | ||
public const string Path = nameof(Path); | ||
public const string RequestPath = nameof(RequestPath); | ||
public const string StatusCode = nameof(StatusCode); | ||
public const string Scheme = nameof(Scheme); | ||
public const string ContentType = nameof(ContentType); | ||
public const string QueryString = nameof(QueryString); | ||
public const string RequestId = nameof(RequestId); | ||
public const string HttpContext = nameof(HttpContext); | ||
|
||
// a known ASP.NET key we don't want to emit under labels.* | ||
public const string HostingRequestFinishedLog = nameof(HostingRequestFinishedLog); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/Elastic.Serilog.Enrichers.Web/Elastic.Serilog.Enrichers.Web.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net6.0;net8.0;net461</TargetFrameworks> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<Title>Elastic Common Schema (ECS) Serilog Enricher for Web proeprties</Title> | ||
<Description>Serilog enricher for ASP.NET (Core) to inject more data in emitted Elastic Common Schema (ECS) documents.</Description> | ||
<IsPackable>True</IsPackable> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Elastic.CommonSchema.Serilog\Elastic.CommonSchema.Serilog.csproj" /> | ||
<ProjectReference Include="..\Elastic.CommonSchema\Elastic.CommonSchema.csproj"/> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<FrameworkReference Condition="$(DefineConstants.Contains(NETCOREAPP))" Include="Microsoft.AspNetCore.App"/> | ||
<Reference Condition="$(DefineConstants.Contains(FULLFRAMEWORK))" Include="System.Web" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Serilog" Version="2.9.0.0"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Remove="Lib\UAParser.regexes.yaml" /> | ||
<EmbeddedResource Include="Lib\UAParser.regexes.yaml" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.