Fix a bug when a relative path is used for the execution log

Fixes #8364

RELNOTES: None
PiperOrigin-RevId: 248786565
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/SpawnLogModule.java b/src/main/java/com/google/devtools/build/lib/bazel/SpawnLogModule.java
index 55779ab..dea75cf 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/SpawnLogModule.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/SpawnLogModule.java
@@ -91,7 +91,7 @@
 
     AsynchronousFileOutputStream outStream = null;
     if (executionOptions.executionLogFile != null) {
-      rawOutput = env.getRuntime().getFileSystem().getPath(executionOptions.executionLogFile);
+      rawOutput = workingDirectory.getRelative(executionOptions.executionLogFile);
       outStream =
           new AsynchronousFileOutputStream(
               workingDirectory.getRelative(executionOptions.executionLogFile));
diff --git a/src/test/shell/bazel/bazel_execlog_test.sh b/src/test/shell/bazel/bazel_execlog_test.sh
index 389e6da..6dfbdc2 100755
--- a/src/test/shell/bazel/bazel_execlog_test.sh
+++ b/src/test/shell/bazel/bazel_execlog_test.sh
@@ -107,4 +107,16 @@
   fi
 }
 
+function test_dir_relative() {
+  cat > BUILD <<'EOF'
+genrule(
+      name = "rule",
+      outs = ["out.txt"],
+      cmd = "echo hello > $(location out.txt)"
+)
+EOF
+  bazel build //:all --experimental_execution_log_file output 2>&1 >> $TEST_log || fail "could not build"
+  wc output || fail "no output produced"
+}
+
 run_suite "execlog_tests"