{"record":{"id":"ac7755cdaf7d621b","repo":"pentaho/pentaho-kettle","slug":"unable-to-close-output-of-file-filename","errorCode":null,"errorMessage":"Unable to close output of file '${filename}'","messagePattern":"Unable to close output of file '(.+?)'","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/logging/FileLoggingEventListener.java","lineNumber":112,"sourceCode":"\n        if ( logToFile ) {\n          String logText = layout.format( event );\n          outputStream.write( logText.getBytes() );\n          outputStream.write( Const.CR.getBytes() );\n        }\n      }\n    } catch ( Exception e ) {\n      exception = new KettleException( \"Unable to write to logging event to file '\" + filename + \"'\", e );\n    }\n  }\n\n  public void close() throws KettleException {\n    try {\n      if ( outputStream != null ) {\n        outputStream.close();\n      }\n    } catch ( Exception e ) {\n      throw new KettleException( \"Unable to close output of file '\" + filename + \"'\", e );\n    }\n  }\n\n  public KettleException getException() {\n    return exception;\n  }\n\n  public void setException( KettleException exception ) {\n    this.exception = exception;\n  }\n\n  public String getFilename() {\n    return filename;\n  }\n\n  public void setFilename( String filename ) {\n    this.filename = filename;\n  }","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/logging/FileLoggingEventListener.java#L94-L130","documentation":"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.","triggerScenarios":"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.","commonSituations":"Long-running jobs writing logs to a network mount that disconnects; cleanup tooling deleting the log file while the transformation runs; container filesystem issues.","solutions":["Check the wrapped cause via getException()/getCause() to identify the filesystem error.","Verify the log target filesystem was available and writable for the whole run (use local disk where possible).","Ensure close() is called once, in a finally block, and not concurrently from multiple threads.","Increase disk space / remove disk-full conditions on the log volume."],"exampleFix":"// before\nlistener.close(); // may throw KettleException\n// after\ntry {\n  listener.close();\n} catch (KettleException e) {\n  log.logError(\"Failed closing log file\", e.getCause() != null ? e.getCause() : e);\n}","handlingStrategy":"try-catch","validationCode":"// Verify target still writable before long runs\nFile f = new File(filename);\nif (!f.getParentFile().canWrite()) throw new IllegalStateException(\"Log dir not writable\");","typeGuard":null,"tryCatchPattern":"try {\n  listener.close();\n} catch (KettleException e) {\n  Throwable root = e.getCause() != null ? e.getCause() : e;\n  log.logError(\"Failed to close log file '\" + filename + \"': \" + root.getMessage(), root);\n} finally {\n  KettleLogStore.getAppender().removeLoggingEventListener(listener);\n}","preventionTips":["Log to local disk rather than volatile network mounts.","Call close() exactly once from a finally block; the listener tracks its own exception via getException().","Monitor disk space on the log volume.","Don't delete or rotate the log file externally while the job runs."],"tags":["kettle","logging","file-io","resource-cleanup"],"backgroundTag":"file-write-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}