From 856d8e1005a70e47fbdaa4126bdfc1f410abf2e8 Mon Sep 17 00:00:00 2001
From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch>
Date: Wed, 14 Mar 2018 00:25:41 +0100
Subject: [PATCH] Reverse components in log file names to start with the host
 name

Refers to #5
---
 ATxService/AutoTx.cs        | 4 ++--
 ATxService/Program.cs       | 2 +-
 Scripts/Install-Service.ps1 | 2 +-
 Scripts/Watch-Logfile.ps1   | 2 +-
 Updater/Update-Service.ps1  | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/ATxService/AutoTx.cs b/ATxService/AutoTx.cs
index 2d9d8ad..622b409 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 = $"var/{ServiceName}.{Environment.MachineName}.log",
+                FileName = $"var/{Environment.MachineName}.{ServiceName}.log",
                 ArchiveAboveSize = 1 * Conv.MegaBytes,
-                ArchiveFileName = $"var/{ServiceName}.{Environment.MachineName}" + ".{#}.log",
+                ArchiveFileName = $"var/{Environment.MachineName}.{ServiceName}" + ".{#}.log",
                 MaxArchiveFiles = 9,
                 KeepFileOpen = true,
                 Layout = LogFormatDefault,
diff --git a/ATxService/Program.cs b/ATxService/Program.cs
index 567c813..cc42e58 100644
--- a/ATxService/Program.cs
+++ b/ATxService/Program.cs
@@ -24,7 +24,7 @@ namespace ATxService
                 var startupLog = Path.Combine(
                     AppDomain.CurrentDomain.BaseDirectory,
                     "var",
-                    "startup.log");
+                    $"{Environment.MachineName}.startup.log");
                 using (var sw = File.AppendText(startupLog))
                 {
                     sw.WriteLine(ex.Message);
diff --git a/Scripts/Install-Service.ps1 b/Scripts/Install-Service.ps1
index ae40ead..f3f047f 100644
--- a/Scripts/Install-Service.ps1
+++ b/Scripts/Install-Service.ps1
@@ -93,7 +93,7 @@ if (Test-Path $LocalConfiguration) {
     Exit
 }
 
-$ServiceLog = "$($ServiceDir)\$($ServiceName).log"
+$ServiceLog = "$($ServiceDir)\var\$($env:COMPUTERNAME).$($ServiceName).log"
 
 
 $Service = Get-Service $ServiceName -ErrorAction SilentlyContinue
diff --git a/Scripts/Watch-Logfile.ps1 b/Scripts/Watch-Logfile.ps1
index 3ad6dd3..da9a9ed 100644
--- a/Scripts/Watch-Logfile.ps1
+++ b/Scripts/Watch-Logfile.ps1
@@ -6,7 +6,7 @@ if (Test-Path $LocalConfiguration) {
 	Exit
 }
 
-$LogFile = "$($ServiceDir)\var\$($ServiceName).$($env:COMPUTERNAME).log"
+$LogFile = "$($ServiceDir)\var\$($env:COMPUTERNAME).$($ServiceName).log"
 
 if (Test-Path $LogFile) {
 	Write-Host "Watching logfile '$LogFile':"
diff --git a/Updater/Update-Service.ps1 b/Updater/Update-Service.ps1
index b83ee5a..3cd099e 100644
--- a/Updater/Update-Service.ps1
+++ b/Updater/Update-Service.ps1
@@ -617,7 +617,7 @@ $ServiceRunningBefore = ServiceIsRunning $ServiceName
 
 $ConfigPath = "$($InstallationPath)\conf"
 $LogPath = "$($InstallationPath)\var"
-$LogFilePfx = "$($LogPath)\$($ServiceName).$($env:COMPUTERNAME)"
+$LogFilePfx = "$($LogPath)\$($env:COMPUTERNAME).$($ServiceName)"
 $StatusXml = "$($InstallationPath)\var\status.xml"
 
 
-- 
GitLab