Fix json target
This commit is contained in:
parent
0ed5a164e8
commit
19f33dbb2c
@ -75,6 +75,7 @@ Public Class LogConfig
|
||||
Private Const FILE_NAME_FORMAT_DEBUG As String = "${shortdate}-${var:product}${var:suffix}${event-properties:item=ModuleName}-Debug.log"
|
||||
Private Const FILE_NAME_FORMAT_TRACE As String = "${shortdate}-${var:product}${var:suffix}${event-properties:item=ModuleName}-Trace.log"
|
||||
Private Const FILE_NAME_FORMAT_ERROR As String = "${shortdate}-${var:product}${var:suffix}${event-properties:item=ModuleName}-Error.log"
|
||||
Private Const FILE_NAME_FORMAT_JSON As String = "${shortdate}-${var:product}${var:suffix}${event-properties:item=ModuleName}.log.json"
|
||||
|
||||
Private Const TARGET_DEFAULT As String = "defaultTarget"
|
||||
Private Const TARGET_ERROR_EX As String = "errorExceptionTarget"
|
||||
@ -455,6 +456,7 @@ Public Class LogConfig
|
||||
_config.AddTarget(TARGET_DEFAULT, GetDefaultLogTarget(_basePath))
|
||||
_config.AddTarget(TARGET_DEBUG, GetDebugLogTarget(_basePath))
|
||||
_config.AddTarget(TARGET_TRACE, GetTraceLogTarget(_basePath))
|
||||
_config.AddTarget(TARGET_JSON, GetJsonLogTarget(_basePath))
|
||||
'_config.AddTarget(TARGET_MEMORY, GetMemoryDebugTarget())
|
||||
|
||||
' Add default rules
|
||||
@ -524,20 +526,6 @@ Public Class LogConfig
|
||||
|
||||
#Region "Log Targets"
|
||||
Private Function GetJsonLogTarget(basePath As String) As FileTarget
|
||||
Dim defaultLog As New FileTarget() With {
|
||||
.FileName = Path.Combine(basePath, FILE_NAME_FORMAT_DEFAULT),
|
||||
.Name = TARGET_JSON,
|
||||
.Layout = LOG_FORMAT_DEFAULT,
|
||||
.MaxArchiveFiles = MAX_ARCHIVE_FILES_DEFAULT,
|
||||
.ArchiveEvery = ARCHIVE_EVERY,
|
||||
.KeepFileOpen = KEEP_FILES_OPEN,
|
||||
.Encoding = Text.Encoding.Unicode
|
||||
}
|
||||
|
||||
Return defaultLog
|
||||
End Function
|
||||
|
||||
Private Function GetDefaultLogTarget(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}"))
|
||||
@ -547,10 +535,24 @@ Public Class LogConfig
|
||||
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}"))
|
||||
|
||||
Dim jsonLog As New FileTarget() With {
|
||||
.FileName = Path.Combine(basePath, FILE_NAME_FORMAT_JSON),
|
||||
.Name = TARGET_JSON,
|
||||
.Layout = oJsonLayout,
|
||||
.MaxArchiveFiles = MAX_ARCHIVE_FILES_DEFAULT,
|
||||
.ArchiveEvery = ARCHIVE_EVERY,
|
||||
.KeepFileOpen = KEEP_FILES_OPEN,
|
||||
.Encoding = Text.Encoding.Unicode
|
||||
}
|
||||
|
||||
Return jsonLog
|
||||
End Function
|
||||
|
||||
Private Function GetDefaultLogTarget(basePath As String) As FileTarget
|
||||
Dim defaultLog As New FileTarget() With {
|
||||
.FileName = Path.Combine(basePath, FILE_NAME_FORMAT_DEFAULT),
|
||||
.Name = TARGET_DEFAULT,
|
||||
.Layout = oJsonLayout,
|
||||
.Layout = LOG_FORMAT_DEFAULT,
|
||||
.MaxArchiveFiles = MAX_ARCHIVE_FILES_DEFAULT,
|
||||
.ArchiveEvery = ARCHIVE_EVERY,
|
||||
.KeepFileOpen = KEEP_FILES_OPEN,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user