From e63d1ea5579a020242eb808f12e6c5f9c150038f Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Fri, 1 Sep 2023 13:56:37 +0200 Subject: [PATCH] Logging: Improve json logging --- Logging/LogConfig.vb | 14 +++++++------- Logging/LogEntry.vb | 9 +++++++++ Logging/Logging.vbproj | 1 + 3 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 Logging/LogEntry.vb diff --git a/Logging/LogConfig.vb b/Logging/LogConfig.vb index 97208491..3524a072 100644 --- a/Logging/LogConfig.vb +++ b/Logging/LogConfig.vb @@ -527,13 +527,13 @@ Public Class LogConfig #Region "Log Targets" Private Function GetJsonLogTarget(basePath As String) As FileTarget Dim oJsonLayout = New Layouts.JsonLayout - oJsonLayout.Attributes.Add(New Layouts.JsonAttribute("level", "${level}")) - oJsonLayout.Attributes.Add(New Layouts.JsonAttribute("message", "${message}")) - oJsonLayout.Attributes.Add(New Layouts.JsonAttribute("date", "${shortdate}")) - oJsonLayout.Attributes.Add(New Layouts.JsonAttribute("product", "${var:product}")) - oJsonLayout.Attributes.Add(New Layouts.JsonAttribute("suffix", "${var:suffix}")) - oJsonLayout.Attributes.Add(New Layouts.JsonAttribute("module", "${event-properties:item=ModuleName}")) - oJsonLayout.Attributes.Add(New Layouts.JsonAttribute("exception", "${exception:format=Message,StackTrace:innerFormat=Message:maxInnerExceptionLevel=3}")) + oJsonLayout.Attributes.Add(New Layouts.JsonAttribute("Level", "${level}")) + oJsonLayout.Attributes.Add(New Layouts.JsonAttribute("Message", "${message}")) + oJsonLayout.Attributes.Add(New Layouts.JsonAttribute("Time", "${date}")) + oJsonLayout.Attributes.Add(New Layouts.JsonAttribute("Product", "${var:product}")) + oJsonLayout.Attributes.Add(New Layouts.JsonAttribute("Suffix", "${var:suffix}")) + oJsonLayout.Attributes.Add(New Layouts.JsonAttribute("Module", "${event-properties:item=ModuleName}")) + oJsonLayout.Attributes.Add(New Layouts.JsonAttribute("Exception", "${exception:format=@,StackTrace:innerFormat=@:maxInnerExceptionLevel=3}")) Dim jsonLog As New FileTarget() With { .FileName = Path.Combine(basePath, FILE_NAME_FORMAT_JSON), diff --git a/Logging/LogEntry.vb b/Logging/LogEntry.vb new file mode 100644 index 00000000..5c1b984b --- /dev/null +++ b/Logging/LogEntry.vb @@ -0,0 +1,9 @@ +Public Class LogEntry + Public Property Level As String + Public Property Message As String + Public Property Product As String + Public Property Time As Date + Public Property Suffix As String + Public Property [Module] As String + Public Property Exception As String +End Class diff --git a/Logging/Logging.vbproj b/Logging/Logging.vbproj index 4a872a75..72d00292 100644 --- a/Logging/Logging.vbproj +++ b/Logging/Logging.vbproj @@ -74,6 +74,7 @@ +