pentaho/pentaho-kettle · error · KettleException

Unable to close output of file

Error message

Unable to close output of file '${filename}'

What it means

FileLoggingEventListener.close() closes the VFS output stream opened in the constructor. If outputStream.close() throws (disk full, file deleted/locked mid-write, filesystem failure), the IOException is wrapped in a KettleException with the filename. Callers such as Trans/Job execute() invoke this when stopping file logging.

Solutions

  1. Check the wrapped cause via getException()/getCause() to identify the filesystem error.
  2. Verify the log target filesystem was available and writable for the whole run (use local disk where possible).
  3. Ensure close() is called once, in a finally block, and not concurrently from multiple threads.
  4. Increase disk space / remove disk-full conditions on the log volume.

Example fix

// before
listener.close(); // may throw KettleException
// after
try {
  listener.close();
} catch (KettleException e) {
  log.logError("Failed closing log file", e.getCause() != null ? e.getCause() : e);
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify target still writable before long runs
File f = new File(filename);
if (!f.getParentFile().canWrite()) throw new IllegalStateException("Log dir not writable");

Try / catch

try {
  listener.close();
} catch (KettleException e) {
  Throwable root = e.getCause() != null ? e.getCause() : e;
  log.logError("Failed to close log file '" + filename + "': " + root.getMessage(), root);
} finally {
  KettleLogStore.getAppender().removeLoggingEventListener(listener);
}

Prevention

When it happens

Trigger: Calling close() (directly or via job/trans execute paths) after the underlying VFS file handle became invalid or the filesystem errors during close — e.g. disk full, file removed externally, network share dropped.

Common situations: Long-running jobs writing logs to a network mount that disconnects; cleanup tooling deleting the log file while the transformation runs; container filesystem issues.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/ac7755cdaf7d621b. Report an issue: GitHub.

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/core/logging/FileLoggingEventListener.java:112

        if ( logToFile ) {
          String logText = layout.format( event );
          outputStream.write( logText.getBytes() );
          outputStream.write( Const.CR.getBytes() );
        }
      }
    } catch ( Exception e ) {
      exception = new KettleException( "Unable to write to logging event to file '" + filename + "'", e );
    }
  }

  public void close() throws KettleException {
    try {
      if ( outputStream != null ) {
        outputStream.close();
      }
    } catch ( Exception e ) {
      throw new KettleException( "Unable to close output of file '" + filename + "'", e );
    }
  }

  public KettleException getException() {
    return exception;
  }

  public void setException( KettleException exception ) {
    this.exception = exception;
  }

  public String getFilename() {
    return filename;
  }

  public void setFilename( String filename ) {
    this.filename = filename;
  }

View on GitHub (pinned to f3058517a1)