Skip to content

Commit

Permalink
Separate logging parameters for Indexer and Interface
Browse files Browse the repository at this point in the history
  • Loading branch information
sarkikos committed Feb 21, 2024
1 parent 0a5ae14 commit f737853
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 30 deletions.
8 changes: 4 additions & 4 deletions aspnetcore/openshift/indexer/template-indexer-devel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,16 @@ objects:
configMapKeyRef:
name: publicapi-api-config-devel
key: "Serilog__Properties__WoodLogProjectNumber"
- name: "Serilog__Properties__WoodLogRetentionMonths"
- name: "Serilog__Properties__WoodLogRetentionMonthsIndexer"
valueFrom:
configMapKeyRef:
name: publicapi-api-config-devel
key: "Serilog__Properties__WoodLogRetentionMonths"
- name: "Serilog__Properties__WoodLogUsecase"
key: "Serilog__Properties__WoodLogRetentionMonthsIndexer"
- name: "Serilog__Properties__WoodLogUsecaseIndexer"
valueFrom:
configMapKeyRef:
name: publicapi-api-config-devel
key: "Serilog__Properties__WoodLogUsecase"
key: "Serilog__Properties__WoodLogUsecaseIndexer"
- name: "QueryTimeout"
valueFrom:
configMapKeyRef:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@ objects:
configMapKeyRef:
name: publicapi-api-config-devel
key: "Serilog__Properties__WoodLogProjectNumber"
- name: "Serilog__Properties__WoodLogRetentionMonths"
- name: "Serilog__Properties__WoodLogRetentionMonthsIndexer"
valueFrom:
configMapKeyRef:
name: publicapi-api-config-devel
key: "Serilog__Properties__WoodLogRetentionMonths"
- name: "Serilog__Properties__WoodLogUsecase"
key: "Serilog__Properties__WoodLogRetentionMonthsIndexer"
- name: "Serilog__Properties__WoodLogUsecaseIndexer"
valueFrom:
configMapKeyRef:
name: publicapi-api-config-devel
key: "Serilog__Properties__WoodLogUsecase"
key: "Serilog__Properties__WoodLogUsecaseIndexer"
- name: "QueryTimeout"
valueFrom:
configMapKeyRef:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@ objects:
configMapKeyRef:
name: publicapi-api-config-production
key: "Serilog__Properties__WoodLogProjectNumber"
- name: "Serilog__Properties__WoodLogRetentionMonths"
- name: "Serilog__Properties__WoodLogRetentionMonthsIndexer"
valueFrom:
configMapKeyRef:
name: publicapi-api-config-production
key: "Serilog__Properties__WoodLogRetentionMonths"
- name: "Serilog__Properties__WoodLogUsecase"
key: "Serilog__Properties__WoodLogRetentionMonthsIndexer"
- name: "Serilog__Properties__WoodLogUsecaseIndexer"
valueFrom:
configMapKeyRef:
name: publicapi-api-config-production
key: "Serilog__Properties__WoodLogUsecase"
key: "Serilog__Properties__WoodLogUsecaseIndexer"
- name: "QueryTimeout"
valueFrom:
configMapKeyRef:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@ objects:
configMapKeyRef:
name: publicapi-api-config-qa
key: "Serilog__Properties__WoodLogProjectNumber"
- name: "Serilog__Properties__WoodLogRetentionMonths"
- name: "Serilog__Properties__WoodLogRetentionMonthsIndexer"
valueFrom:
configMapKeyRef:
name: publicapi-api-config-qa
key: "Serilog__Properties__WoodLogRetentionMonths"
- name: "Serilog__Properties__WoodLogUsecase"
key: "Serilog__Properties__WoodLogRetentionMonthsIndexer"
- name: "Serilog__Properties__WoodLogUsecaseIndexer"
valueFrom:
configMapKeyRef:
name: publicapi-api-config-qa
key: "Serilog__Properties__WoodLogUsecase"
key: "Serilog__Properties__WoodLogUsecaseIndexer"
- name: "QueryTimeout"
valueFrom:
configMapKeyRef:
Expand Down
8 changes: 4 additions & 4 deletions aspnetcore/openshift/indexer/template-indexer-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,16 @@ objects:
configMapKeyRef:
name: publicapi-api-config-production
key: "Serilog__Properties__WoodLogProjectNumber"
- name: "Serilog__Properties__WoodLogRetentionMonths"
- name: "Serilog__Properties__WoodLogRetentionMonthsIndexer"
valueFrom:
configMapKeyRef:
name: publicapi-api-config-production
key: "Serilog__Properties__WoodLogRetentionMonths"
- name: "Serilog__Properties__WoodLogUsecase"
key: "Serilog__Properties__WoodLogRetentionMonthsIndexer"
- name: "Serilog__Properties__WoodLogUsecaseIndexer"
valueFrom:
configMapKeyRef:
name: publicapi-api-config-production
key: "Serilog__Properties__WoodLogUsecase"
key: "Serilog__Properties__WoodLogUsecaseIndexer"
- name: "QueryTimeout"
valueFrom:
configMapKeyRef:
Expand Down
8 changes: 4 additions & 4 deletions aspnetcore/openshift/indexer/template-indexer-qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,16 @@ objects:
configMapKeyRef:
name: publicapi-api-config-qa
key: "Serilog__Properties__WoodLogProjectNumber"
- name: "Serilog__Properties__WoodLogRetentionMonths"
- name: "Serilog__Properties__WoodLogRetentionMonthsIndexer"
valueFrom:
configMapKeyRef:
name: publicapi-api-config-qa
key: "Serilog__Properties__WoodLogRetentionMonths"
- name: "Serilog__Properties__WoodLogUsecase"
key: "Serilog__Properties__WoodLogRetentionMonthsIndexer"
- name: "Serilog__Properties__WoodLogUsecaseIndexer"
valueFrom:
configMapKeyRef:
name: publicapi-api-config-qa
key: "Serilog__Properties__WoodLogUsecase"
key: "Serilog__Properties__WoodLogUsecaseIndexer"
- name: "QueryTimeout"
valueFrom:
configMapKeyRef:
Expand Down
29 changes: 23 additions & 6 deletions aspnetcore/src/Logging/HttpSinkWoodLogMetadataFormatterBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ public class WoodLogMetadataFormatterBase : ITextFormatter
/// </summary>
protected bool IncludeRenderedMessage { get; set; }

/// <summary>
/// Gets or sets a value indicating which application is being logged (Indexer or Interface).
/// </summary>
protected string ApplicationType { get; set; }


/// <summary>
/// Format the log event into the output.
/// </summary>
Expand Down Expand Up @@ -102,7 +108,7 @@ private void FormatContent(LogEvent logEvent, TextWriter output)

if (logEvent.Properties.Count != 0)
{
WriteProperties(logEvent.Properties, output);
WriteProperties(logEvent.Properties, output, ApplicationType);
}

// Better not to allocate an array in the 99.9% of cases where this is false
Expand All @@ -122,7 +128,8 @@ private void FormatContent(LogEvent logEvent, TextWriter output)

private static void WriteProperties(
IReadOnlyDictionary<string, LogEventPropertyValue> properties,
TextWriter output)
TextWriter output,
string ApplicationType)
{
output.Write(",\"Properties\":{");

Expand All @@ -137,9 +144,11 @@ private static void WriteProperties(
* Wood project number:
* Serilog.Properties.WoodLogProjectNumber
* Wood use case:
* Serilog.Properties.WoodLogUseCase
* Serilog.Properties.WoodLogUseCaseIndexer
* Serilog.Properties.WoodLogUseCaseInterface
* Wood retention months:
* Serilog.Properties.WoodLogRetentionMonths
* Serilog.Properties.WoodLogRetentionMonthsIndexer
* Serilog.Properties.WoodLogRetentionMonthsInterface
*
* Properties are excluded from the "Properties" section of
* outgoing JSON log message. Instead, a new top level
Expand Down Expand Up @@ -172,11 +181,19 @@ private static void WriteProperties(
{
woodProjectNumber = property;
}
else if (property.Key.ToLower() == "woodlogusecase")
else if (ApplicationType == "Indexer" && property.Key.ToLower() == "woodlogusecaseindexer")
{
woodUseCase = property;
}
else if (property.Key.ToLower() == "woodlogretentionmonths")
else if (ApplicationType == "Interface" && property.Key.ToLower() == "woodlogusecaseinterface")
{
woodUseCase = property;
}
else if (ApplicationType == "Indexer" && property.Key.ToLower() == "woodlogretentionmonthsindexer")
{
woodRetentionMonths = property;
}
else if (ApplicationType == "Interface" && property.Key.ToLower() == "woodlogretentionmonthsinterface")
{
woodRetentionMonths = property;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ public WoodLogMetadataFormatterForIndexer()
{
IncludeMessageTemplate = false;
IncludeRenderedMessage = true;
ApplicationType = "Indexer";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ public WoodLogMetadataFormatterForInterface()
{
IncludeMessageTemplate = false;
IncludeRenderedMessage = false;
ApplicationType = "Interface";
}
}

0 comments on commit f737853

Please sign in to comment.