Skip to content

Commit

Permalink
Add environment variables to enable service logging in the MSSQL and …
Browse files Browse the repository at this point in the history
…Kusto kernels (#2608)

* Add environment variable for enabling logging for SQL and Kusto kernels.

* Use file instead of folder

* Fix arguments

* Use better string building logic
  • Loading branch information
corivera authored Jan 10, 2023
1 parent 45db0c6 commit 02e9bb6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/Microsoft.DotNet.Interactive.Kql/KqlKernelConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ public async Task<Kernel> CreateKernelAsync(string kernelName)

var connectionDetails = await BuildConnectionDetailsAsync();

var client = new ToolsServiceClient(PathToService);
var serviceArgs = $"--parent-pid {Environment.ProcessId}";
var logFile = Environment.GetEnvironmentVariable("DOTNET_KUSTOSERVICE_LOGFILE");
if (!string.IsNullOrWhiteSpace(logFile))
{
var logArgs = $" --log-file \"{logFile}\" --tracing-level Verbose";
serviceArgs += logArgs;
}

var client = new ToolsServiceClient(PathToService, serviceArgs);

var kernel = new MsKqlKernel(
$"kql-{kernelName}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ public async Task<Kernel> CreateKernelAsync(string kernelName)
throw new InvalidOperationException($"{nameof(PathToService)} cannot be null or whitespace.");
}

var client = new ToolsServiceClient(PathToService, $"--parent-pid {Environment.ProcessId}");
var serviceArgs = $"--parent-pid {Environment.ProcessId}";
var logFile = Environment.GetEnvironmentVariable("DOTNET_SQLTOOLSSERVICE_LOGFILE");
if (!string.IsNullOrWhiteSpace(logFile))
{
var logArgs = $" --log-file \"{logFile}\" --tracing-level Verbose";
serviceArgs += logArgs;
}

var client = new ToolsServiceClient(PathToService, serviceArgs);

var kernel = new MsSqlKernel(
$"sql-{kernelName}",
Expand Down

0 comments on commit 02e9bb6

Please sign in to comment.