remove ClassNLog in favor of logging module, remove calls to logger.fatal

This commit is contained in:
Jonathan Jenne
2019-11-12 10:57:55 +01:00
parent a64d3461a7
commit 7a2ff1a978
3 changed files with 3 additions and 32 deletions

View File

@@ -1,27 +0,0 @@
Public Class ClassNLog
Public Shared Function GetLogPathFor(moduleName As String)
Dim localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
Return IO.Path.Combine(localAppData, "Digital Data", "UserManager", "Log")
End Function
Public Shared Function GetLoggerConfigFor(moduleName As String)
Dim loggerConfig = New NLog.Config.LoggingConfiguration()
Dim logFileName = Environment.UserName & "-${date:format=yyyy-MM-dd}.log"
Dim logPath As String = IO.Path.Combine(GetLogPathFor(moduleName), logFileName)
Dim logFileInfo As New NLog.Targets.FileTarget("logFileInfo") With {
.FileName = logPath,
.Layout = "${longdate}|${level:uppercase=true}|${logger}|${message}"
}
Dim logFileError As New NLog.Targets.FileTarget("logFileError") With {
.FileName = logPath,
.Layout = "${longdate}|${level:uppercase=true}|${logger}|${message}|${exception:format=message}" & vbCrLf & "${exception:format=toString}"
}
loggerConfig.AddRule(NLog.LogLevel.Debug, NLog.LogLevel.Warn, logFileInfo)
loggerConfig.AddRule(NLog.LogLevel.Error, NLog.LogLevel.Fatal, logFileError)
Return loggerConfig
End Function
End Class

View File

@@ -55,7 +55,6 @@
<Reference Include="DevExpress.Printing.v18.1.Core, Version=18.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" /> <Reference Include="DevExpress.Printing.v18.1.Core, Version=18.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<Reference Include="DevExpress.Sparkline.v18.1.Core, Version=18.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" /> <Reference Include="DevExpress.Sparkline.v18.1.Core, Version=18.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<Reference Include="DevExpress.Utils.v18.1, Version=18.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" /> <Reference Include="DevExpress.Utils.v18.1, Version=18.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<Reference Include="DevExpress.XtraEditors.v18.1, Version=18.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DevExpress.XtraEditors.v18.1, Version=18.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" /> <Reference Include="DevExpress.XtraEditors.v18.1, Version=18.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<Reference Include="DevExpress.XtraGrid.v18.1, Version=18.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" /> <Reference Include="DevExpress.XtraGrid.v18.1, Version=18.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="DevExpress.XtraLayout.v18.1, Version=18.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" /> <Reference Include="DevExpress.XtraLayout.v18.1, Version=18.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
@@ -111,7 +110,6 @@
<Compile Include="ApplicationEvents.vb" /> <Compile Include="ApplicationEvents.vb" />
<Compile Include="ClassData.vb" /> <Compile Include="ClassData.vb" />
<Compile Include="ClassDragDrop.vb" /> <Compile Include="ClassDragDrop.vb" />
<Compile Include="ClassNLog.vb" />
<Compile Include="DS_ChangeS.Designer.vb"> <Compile Include="DS_ChangeS.Designer.vb">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>

View File

@@ -125,7 +125,7 @@ Public Class frmMain
End If End If
Catch ex As Exception Catch ex As Exception
MsgBox("Unexpected Error while loading. Please check the log.", MsgBoxStyle.Critical, "User Manager") MsgBox("Unexpected Error while loading. Please check the log.", MsgBoxStyle.Critical, "User Manager")
MyLogger.Fatal(ex, "Unexpected Error while loading.") MyLogger.Error(ex, "Unexpected Error while loading.")
End Try End Try
End Sub End Sub
@@ -1072,7 +1072,7 @@ Public Class frmMain
End Sub End Sub
Private Sub btnOpenLogDir_Click(sender As Object, e As EventArgs) Handles btnOpenLogDir.Click Private Sub btnOpenLogDir_Click(sender As Object, e As EventArgs) Handles btnOpenLogDir.Click
Process.Start(ClassNLog.GetLogPathFor(MODULE_NAME)) Process.Start(MyLogConfig.LogDirectory)
End Sub End Sub
Private Sub txtADRootNode_Leave(sender As Object, e As EventArgs) Handles txtADRootNode.Leave, txtLDAPGroupQuery.Leave, txtLDAPUserQuery.Leave Private Sub txtADRootNode_Leave(sender As Object, e As EventArgs) Handles txtADRootNode.Leave, txtLDAPGroupQuery.Leave, txtLDAPUserQuery.Leave
@@ -1135,7 +1135,7 @@ Public Class frmMain
End Sub End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click, Button4.Click Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click, Button4.Click
MyConfig.Config.AdGroupFilter = txtLDAPGroupQuery.Text MyConfig.Config.AdUserFilter = txtLDAPUserQuery.Text
MyConfig.Save() MyConfig.Save()
End Sub End Sub