Skip to content

Commit 8df7cf8

Browse files
committed
Don't write to the error log before it's configured.
1 parent 0bf1672 commit 8df7cf8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/GitVersionExe/Program.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ static void ConfigureLogging(Arguments arguments)
127127
writeActions.Add(Console.WriteLine);
128128
}
129129

130+
Exception exception = null;
130131
if (arguments.LogFilePath != null && arguments.LogFilePath != "console")
131132
{
132133
try
@@ -148,14 +149,17 @@ static void ConfigureLogging(Arguments arguments)
148149
}
149150
catch (Exception ex)
150151
{
151-
Logger.WriteError(String.Format("Failed to configure logging for '{0}': {1}", arguments.LogFilePath, ex.Message));
152+
exception = ex;
152153
}
153154
}
154155

155156
Logger.SetLoggers(
156157
s => writeActions.ForEach(a => a(s)),
157158
s => writeActions.ForEach(a => a(s)),
158159
s => writeActions.ForEach(a => a(s)));
160+
161+
if (exception != null)
162+
Logger.WriteError(string.Format("Failed to configure logging for '{0}': {1}", arguments.LogFilePath, exception.Message));
159163
}
160164

161165
static void WriteLogEntry(Arguments arguments, string s)

0 commit comments

Comments
 (0)