@@ -155,11 +155,10 @@ public int ProcessId
155155 public string ? DriverServicePath { get ; set ; }
156156
157157 /// <summary>
158- /// Gets or sets a value indicating whether the driver process console output should be logged
159- /// to the console. Defaults to <see langword="false"/>, meaning console output from the
160- /// driver will be suppressed.
158+ /// Collects the driver log output and writes it to the console. Defaults to <see langword="true"/>.
159+ /// Internal variable to avoid using the stream when logs are sent to a file.
161160 /// </summary>
162- public bool LogToConsole { get ; set ; } = false ;
161+ protected bool WriteDriverLogToConsole { get ; set ; } = true ;
163162
164163 /// <summary>
165164 /// Gets the command-line arguments for the driver service.
@@ -253,8 +252,8 @@ public void Start()
253252 this . driverServiceProcess . StartInfo . UseShellExecute = false ;
254253 this . driverServiceProcess . StartInfo . CreateNoWindow = this . HideCommandPromptWindow ;
255254
256- this . driverServiceProcess . StartInfo . RedirectStandardOutput = this . LogToConsole ;
257- this . driverServiceProcess . StartInfo . RedirectStandardError = this . LogToConsole ;
255+ this . driverServiceProcess . StartInfo . RedirectStandardOutput = this . WriteDriverLogToConsole ;
256+ this . driverServiceProcess . StartInfo . RedirectStandardError = this . WriteDriverLogToConsole ;
258257
259258 DriverProcessStartingEventArgs eventArgs = new DriverProcessStartingEventArgs ( this . driverServiceProcess . StartInfo ) ;
260259 this . OnDriverProcessStarting ( eventArgs ) ;
@@ -318,12 +317,12 @@ protected virtual void OnDriverProcessStarted(DriverProcessStartedEventArgs even
318317 throw new ArgumentNullException ( nameof ( eventArgs ) , "eventArgs must not be null" ) ;
319318 }
320319
321- if ( this . LogToConsole && eventArgs . StandardOutputStreamReader != null )
320+ if ( this . WriteDriverLogToConsole && eventArgs . StandardOutputStreamReader != null )
322321 {
323322 _ = Task . Run ( ( ) => ReadStreamAsync ( eventArgs . StandardOutputStreamReader , "stdout" ) ) ;
324323 }
325324
326- if ( this . LogToConsole && eventArgs . StandardErrorStreamReader != null )
325+ if ( this . WriteDriverLogToConsole && eventArgs . StandardErrorStreamReader != null )
327326 {
328327 _ = Task . Run ( ( ) => ReadStreamAsync ( eventArgs . StandardErrorStreamReader , "stderr" ) ) ;
329328 }
0 commit comments