diff --git a/ATxService/AutoTx.cs b/ATxService/AutoTx.cs index 2f95e7fc14cd6ba098bd2f8f2cb2283375e6649d..2d9d8ad3af92af192eddeffd5b06224b42eca5c0 100644 --- a/ATxService/AutoTx.cs +++ b/ATxService/AutoTx.cs @@ -157,9 +157,9 @@ namespace ATxService var logConfig = new LoggingConfiguration(); var fileTarget = new FileTarget { Name = "file", - FileName = ServiceName + ".log", + FileName = $"var/{ServiceName}.{Environment.MachineName}.log", ArchiveAboveSize = 1 * Conv.MegaBytes, - ArchiveFileName = ServiceName + ".{#}.log", + ArchiveFileName = $"var/{ServiceName}.{Environment.MachineName}" + ".{#}.log", MaxArchiveFiles = 9, KeepFileOpen = true, Layout = LogFormatDefault, diff --git a/ATxService/Program.cs b/ATxService/Program.cs index cfab9c97b797027f3be7f73eb70c65a6035fe31a..567c813726665775d724ab1b368132e1fa2b21f4 100644 --- a/ATxService/Program.cs +++ b/ATxService/Program.cs @@ -21,7 +21,10 @@ namespace ATxService } catch (Exception ex) { - var startupLog = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "startup.log"); + var startupLog = Path.Combine( + AppDomain.CurrentDomain.BaseDirectory, + "var", + "startup.log"); using (var sw = File.AppendText(startupLog)) { sw.WriteLine(ex.Message); diff --git a/Scripts/Watch-Logfile.ps1 b/Scripts/Watch-Logfile.ps1 index f939e759ec1d3ea9d13b85f866eb7fa8c2fef1e5..3ad6dd34adf9b8cc0e04a07131249507d4177ee4 100644 --- a/Scripts/Watch-Logfile.ps1 +++ b/Scripts/Watch-Logfile.ps1 @@ -6,7 +6,7 @@ if (Test-Path $LocalConfiguration) { Exit } -$LogFile = $ServiceDir + "\AutoTx.log" +$LogFile = "$($ServiceDir)\var\$($ServiceName).$($env:COMPUTERNAME).log" if (Test-Path $LogFile) { Write-Host "Watching logfile '$LogFile':" diff --git a/Updater/Update-Service.ps1 b/Updater/Update-Service.ps1 index 31182147950801519e0d645c3daa7de878600714..636c6ca9e6e18ee7e7d1c6c762e4fb9093691146 100644 --- a/Updater/Update-Service.ps1 +++ b/Updater/Update-Service.ps1 @@ -159,7 +159,7 @@ function Start-MyService { $ex = $_.Exception.Message $msg = "Trying to start the service results in this error:`n$($ex)`n`n" $msg += " -------------------- last 50 log lines --------------------`n" - $msg += Get-LastLogLines "$($LogFile)" 50 + $msg += Get-LastLogLines "$($LogFilePfx).log" 50 $msg += " -------------------- ----------------- --------------------`n" Send-MailReport -Subject "Startup of service $($ServiceName) failed!" ` -Body $msg @@ -450,16 +450,12 @@ function ServiceUpdate-Requested { function Upload-LogFiles { - $Dest = "$($UploadPathLogs)\$($env:COMPUTERNAME)" - New-Item -Force -Type Directory $Dest | Out-Null try { - Copy-Item -Force -ErrorAction Stop ` - -Path "$($LogFile)" ` - -Destination $Dest - Log-Debug "Uploaded logfile to [$($Dest)]." + Copy-Item -Force -Path "$($LogFilePfx)*.log" -Destination $UploadPathLogs + Log-Debug "Uploaded logfile(s) to [$($UploadPathLogs)]." } catch { - Log-Warning "Uploading logfile FAILED!`n$($_.Exception.Message)" + Log-Warning "Uploading logfile(s) FAILED!`n$($_.Exception.Message)" } } @@ -589,8 +585,8 @@ Log-Debug "$($Me) started..." $ServiceRunningBefore = ServiceIsRunning $ServiceName $ConfigPath = "$($InstallationPath)\conf" -$LogPath = "$($InstallationPath)" -$LogFile = "$($LogPath)\AutoTx.log" +$LogPath = "$($InstallationPath)\var" +$LogFilePfx = "$($LogPath)\$($ServiceName).$($env:COMPUTERNAME)" $StatusXml = "$($InstallationPath)\var\status.xml"