diff --git a/java/src/org/openqa/selenium/remote/service/DriverService.java b/java/src/org/openqa/selenium/remote/service/DriverService.java index a34f594e5ff1a..f5313bf90ed8f 100644 --- a/java/src/org/openqa/selenium/remote/service/DriverService.java +++ b/java/src/org/openqa/selenium/remote/service/DriverService.java @@ -444,8 +444,12 @@ protected Duration getDefaultTimeout() { } protected OutputStream getLogOutput() { + if (logOutputStream != null) { + return logOutputStream; + } try { - return logOutputStream != null ? logOutputStream : new FileOutputStream(logFile); + File logFile = getLogFile(); + return logFile == null ? ByteStreams.nullOutputStream() : new FileOutputStream(logFile); } catch (FileNotFoundException e) { throw new RuntimeException(e); }