Logging: Add Trace logging
This commit is contained in:
parent
b3d8b2d6cf
commit
4fd484d721
@ -73,12 +73,14 @@ Public Class LogConfig
|
||||
|
||||
Private Const FILE_NAME_FORMAT_DEFAULT As String = "${shortdate}-${var:product}${var:suffix}${event-properties:item=ModuleName}.log"
|
||||
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 TARGET_DEFAULT As String = "defaultTarget"
|
||||
Private Const TARGET_ERROR_EX As String = "errorExceptionTarget"
|
||||
Private Const TARGET_ERROR As String = "errorTarget"
|
||||
Private Const TARGET_DEBUG As String = "debugTarget"
|
||||
Private Const TARGET_TRACE As String = "traceTarget"
|
||||
Private Const TARGET_MEMORY As String = "memoryTarget"
|
||||
|
||||
Private Const LOG_FORMAT_BASE As String = "${time}|${logger:shortName=True}|${level:uppercase=true}"
|
||||
@ -252,6 +254,7 @@ Public Class LogConfig
|
||||
|
||||
Dim oLogger = GetLogger()
|
||||
oLogger.Info("Logging started for [{0}{1}] in [{2}]", oProductName, logFileSuffix, LogFile)
|
||||
oLogger.Info("Logging Version [{0}]", Assembly.GetExecutingAssembly().GetName().Version)
|
||||
|
||||
' Clear old Logfiles as defined in `FileKeepInterval`
|
||||
ClearOldLogfiles(FileKeepRangeInDays)
|
||||
@ -427,6 +430,7 @@ Public Class LogConfig
|
||||
_config.AddTarget(TARGET_ERROR, GetErrorLogTarget(_basePath))
|
||||
_config.AddTarget(TARGET_DEFAULT, GetDefaultLogTarget(_basePath))
|
||||
_config.AddTarget(TARGET_DEBUG, GetDebugLogTarget(_basePath))
|
||||
_config.AddTarget(TARGET_TRACE, GetTraceLogTarget(_basePath))
|
||||
_config.AddTarget(TARGET_MEMORY, GetMemoryDebugTarget())
|
||||
|
||||
' Add default rules
|
||||
@ -472,8 +476,9 @@ Public Class LogConfig
|
||||
|
||||
' Add debug rule, if configured
|
||||
If Debug Then
|
||||
_config.AddRuleForAllLevels(TARGET_DEBUG)
|
||||
_config.AddRuleForAllLevels(TARGET_MEMORY)
|
||||
_config.AddRuleForAllLevels(TARGET_TRACE)
|
||||
_config.AddRule(LogLevel.Debug, LogLevel.Error, TARGET_DEBUG)
|
||||
_config.AddRule(LogLevel.Debug, LogLevel.Error, TARGET_MEMORY)
|
||||
End If
|
||||
|
||||
' Reload all running loggers
|
||||
@ -535,6 +540,22 @@ Public Class LogConfig
|
||||
Return debugLog
|
||||
End Function
|
||||
|
||||
Private Function GetTraceLogTarget(basePath As String) As FileTarget
|
||||
Dim debugLog As New FileTarget() With {
|
||||
.FileName = Path.Combine(basePath, FILE_NAME_FORMAT_TRACE),
|
||||
.Name = TARGET_DEBUG,
|
||||
.Layout = LOG_FORMAT_DEBUG,
|
||||
.MaxArchiveFiles = MAX_ARCHIVE_FILES_DEBUG_DETAIL,
|
||||
.ArchiveEvery = ARCHIVE_EVERY,
|
||||
.KeepFileOpen = KEEP_FILES_OPEN_DEBUG,
|
||||
.OpenFileCacheTimeout = OPEN_FILE_CACHE_TIMEOUT,
|
||||
.AutoFlush = AUTO_FLUSH,
|
||||
.OpenFileFlushTimeout = OPEN_FILE_FLUSH_TIMEOUT
|
||||
}
|
||||
|
||||
Return debugLog
|
||||
End Function
|
||||
|
||||
Private Function GetMemoryDebugTarget() As MemoryTarget
|
||||
Dim memoryLog As New MemoryTarget() With {
|
||||
.Layout = LOG_FORMAT_DEBUG,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user