Skip to content

Commit

Permalink
Fix multi-instance logging and make it optional
Browse files Browse the repository at this point in the history
  • Loading branch information
davidebbo committed Dec 5, 2017
1 parent 66e8d2a commit c8b6aa6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions TracingLauncher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ class Program

static int Main(string[] args)
{
bool loggingEnabled = Environment.GetEnvironmentVariable("TRACINGLAUNCHER_ENABLE_LOGGING") == "1";
string roleInstance = Environment.GetEnvironmentVariable("RoleInstance") ?? Environment.MachineName;

string dir = Path.GetDirectoryName(typeof(Program).Assembly.Location);
string logFilePath = Path.Combine(dir, "TracingLauncherLogs.log");
string logFilePath = Path.Combine(dir, $"TracingLauncherLogs_{roleInstance}.log");

using (_logWriter = new StreamWriter(logFilePath))
using (_logWriter = loggingEnabled ? new StreamWriter(logFilePath) : TextWriter.Null)
{
_logWriter.WriteLine("Starting TracingLauncher");

Expand Down

0 comments on commit c8b6aa6

Please sign in to comment.