diff --git a/Modules.Logging/LogConfig.vb b/Modules.Logging/LogConfig.vb
index d490ab7c..b3591fc0 100644
--- a/Modules.Logging/LogConfig.vb
+++ b/Modules.Logging/LogConfig.vb
@@ -214,9 +214,6 @@ Public Class LogConfig
.Configuration = config
}
- Dim l = LogFactory.GetCurrentClassLogger(Of Logger)()
-
-
' Save log paths for files/directory
LogDirectory = basePath
LogFile = GetCurrentLogFilePath()
@@ -227,15 +224,41 @@ Public Class LogConfig
'''
''' An object of Logging.Logger
Public Function GetLogger() As Logger
- Dim name As String = "Unknown"
- Try
- Dim frame As New StackFrame(1)
- Dim method = frame.GetMethod()
- name = method.DeclaringType.FullName
- Catch ex As Exception
- End Try
+ Dim oClassName As String = GetClassFullName()
+ Return LogFactory.GetLogger(Of Logger)(oClassName)
+ End Function
- Return LogFactory.GetLogger(Of Logger)(name)
+ '''
+ ''' Gets the fully qualified name of the class invoking the calling method,
+ ''' including the namespace but Not the assembly.
+ '''
+ ''' The fully qualified class name
+ ''' This method is very resource-intensive!
+ Public Shared Function GetClassFullName() As String
+ Dim oFramesToSkip As Integer = 2
+ Dim oClassName As String = String.Empty
+ Dim oStackTrace = Environment.StackTrace
+ Dim oStackTraceLines = oStackTrace.Replace(vbCr, "").Split({vbLf}, StringSplitOptions.RemoveEmptyEntries)
+
+ For i As Integer = 0 To oStackTraceLines.Length - 1
+ Dim oCallingClassAndMethod = oStackTraceLines(i).Split({" ", "<>", "(", ")"}, StringSplitOptions.RemoveEmptyEntries)(1)
+ Dim oMethodStartIndex As Integer = oCallingClassAndMethod.LastIndexOf(".", StringComparison.Ordinal)
+
+ If oMethodStartIndex > 0 Then
+ Dim oCallingClass = oCallingClassAndMethod.Substring(0, oMethodStartIndex)
+ oClassName = oCallingClass.TrimEnd("."c)
+
+ If Not oClassName.StartsWith("System.Environment") AndAlso oFramesToSkip <> 0 Then
+ i += oFramesToSkip - 1
+ oFramesToSkip = 0
+ Continue For
+ End If
+
+ If Not oClassName.StartsWith("System.") Then Exit For
+ End If
+ Next
+
+ Return oClassName
End Function
'''