diff --git a/Modules.Logging/LogConfig.vb b/Modules.Logging/LogConfig.vb
index 2fb378e0..13dc0281 100644
--- a/Modules.Logging/LogConfig.vb
+++ b/Modules.Logging/LogConfig.vb
@@ -4,7 +4,7 @@ Imports NLog.Config
Imports NLog.Targets
''' LogConfig
-''' 0.0.0.7
+''' 0.0.1.0
''' 02.10.2018
'''
''' Module that writes file-logs to different locations:
@@ -100,6 +100,7 @@ Public Class LogConfig
Private Const TARGET_ERROR As String = "errorTarget"
Private Const TARGET_DETAIL As String = "detailTarget"
Private Const TARGET_DEBUG As String = "debugTarget"
+ Private Const TARGET_MEMORY As String = "memoryTarget"
Private Const DATE_FORMAT_LONG As String = "${longdate}"
Private Const DATE_FORMAT_DEFAULT As String = "${date:format=yyyy-MM-dd HH\:mm\:ss}"
@@ -110,6 +111,7 @@ Public Class LogConfig
Private Const LOG_FORMAT_DEFAULT As String = LOG_FORMAT_BASE & " >> ${message}"
Private Const LOG_FORMAT_EXCEPTION As String = LOG_FORMAT_BASE & " >> ${exception:format=Message}${newline}${exception:format=StackTrace}"
Private Const LOG_FORMAT_DEBUG As String = LOG_FORMAT_BASE_LONG_DATE & " >> ${message}"
+ Private Const LOG_FORMAT_MEMORY As String = "${message}${newline}${exception:format=Message}${newline}${exception:format=StackTrace}"
Private Const FOLDER_NAME_LOG = "Log"
Private Const FILE_NAME_ACCESS_TEST = "accessTest.txt"
@@ -158,6 +160,22 @@ Public Class LogConfig
End Set
End Property
+ '''
+ ''' Returns Logs in Memory as List(Of String) if Debug is enabled
+ ''' Returns nothing if debug is disabled
+ '''
+ ''' A list of log messages
+ Public ReadOnly Property Logs As List(Of String)
+ Get
+ If Debug = False Then
+ Return Nothing
+ End If
+
+ Dim oTarget = config.FindTargetByName(Of MemoryTarget)(TARGET_MEMORY)
+ Return oTarget?.Logs.ToList()
+ End Get
+ End Property
+
'''
''' Initializes a new LogConfig object with a logpath and optinally a filename-suffix.
'''
@@ -288,6 +306,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_MEMORY, GetMemoryDebugTarget())
' Add default rules
AddDefaultRules(config)
@@ -333,6 +352,7 @@ Public Class LogConfig
' Add debug rule, if configured
If Debug Then
config.AddRuleForOneLevel(LogLevel.Debug, TARGET_DEBUG)
+ config.AddRuleForAllLevels(TARGET_MEMORY)
End If
' Reload all running loggers
@@ -402,5 +422,15 @@ Public Class LogConfig
Return debugLog
End Function
+
+ Private Function GetMemoryDebugTarget() As MemoryTarget
+ Dim memoryLog As New MemoryTarget() With {
+ .Layout = LOG_FORMAT_MEMORY,
+ .Name = TARGET_MEMORY,
+ .OptimizeBufferReuse = True
+ }
+
+ Return memoryLog
+ End Function
#End Region
End Class
diff --git a/Modules.Logging/My Project/AssemblyInfo.vb b/Modules.Logging/My Project/AssemblyInfo.vb
index 7df792a5..89147117 100644
--- a/Modules.Logging/My Project/AssemblyInfo.vb
+++ b/Modules.Logging/My Project/AssemblyInfo.vb
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
'
-
+