Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 5de119c6 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

change nlog log path if mode is set to installed

parent fa63a57f
No related branches found
No related tags found
No related merge requests found
......@@ -12,9 +12,13 @@ Imports System.Collections.Generic
Imports System.IO
Imports System.Linq
Imports System.Text
Imports NLog
Imports NLog.Targets
Imports NLog.Targets.Wrappers
Imports TUGraz.VectoCommon.Utils
Imports TUGraz.VectoCore.Utils
Namespace My
' The following events are available for MyApplication:
'
......@@ -46,9 +50,20 @@ Namespace My
ReadInstallMode()
MyConfPath = path.Combine(MyAppPath, CONFIG_FOLDER)
MyLogPath = ""
if (InstallModeInstalled) Then
MyConfPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), APP_DATA_VENDOR_PATH, VectoSimulationCore.VersionNumber, CONFIG_FOLDER)
MyLogPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), APP_DATA_VENDOR_PATH, VectoSimulationCore.VersionNumber)
Dim logTarget As FileTarget = TryCast(LogManager.Configuration.FindTargetByName("LogFile"), FileTarget)
if (logTarget is Nothing) Then
logTarget = CType(TryCast(LogManager.Configuration.FindTargetByName("LogFile"), WrapperTargetBase).WrappedTarget, FileTarget)
End If
if (Not (logTarget Is Nothing)) then
logTarget.FileName = Path.Combine(MyLogPath, "logs", "log.txt")
LogManager.ReconfigExistingLoggers()
End If
End If
FileHistoryPath = path.Combine(MyConfPath, CONFIG_FILE_HISTORY_FOLDER)
......@@ -56,22 +71,22 @@ Namespace My
'If folder does not exist: Create!
If Not Directory.Exists(MyLogPath) Then
Try
Directory.CreateDirectory(MyLogPath)
Catch ex As Exception
MsgBox("Failed to create directory '" & MyLogPath & "'!", MsgBoxStyle.Critical)
'LogFile.WriteToLog(MessageType.Err, "Failed to create directory '" & MyLogPath & "'!")
e.Cancel = True
End Try
End If
'Log
LogFile = New FileLogger
If Not LogFile.StartLog() Then
MsgBox("Error! Can't access log file. Application folder needs read/write permissions!")
e.Cancel = True
End If
If Not String.IsNullOrWhiteSpace(MyLogPath) AndAlso Not Directory.Exists(MyLogPath) Then
Try
Directory.CreateDirectory(MyLogPath)
Catch ex As Exception
MsgBox("Failed to create directory '" & MyLogPath & "'!", MsgBoxStyle.Critical)
'LogFile.WriteToLog(MessageType.Err, "Failed to create directory '" & MyLogPath & "'!")
e.Cancel = True
End Try
End If
'Log
LogFile = New FileLogger
If Not LogFile.StartLog() Then
MsgBox("Error! Can't access log file. Application folder needs read/write permissions!")
e.Cancel = True
End If
If Not Directory.Exists(MyConfPath) Then
Try
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment