pentaho/pentaho-kettle · error · KettleException
There was an error while trying to open file '' for writing
Error message
There was an error while trying to open file '' for writing
What it means
The LogChannelFileWriter constructor opens the target log file through KettleVFS for writing (optionally appending) and wraps any IOException in this KettleException. It means the specified log file could not be opened for output at the moment the writer was created.
Solutions
- Verify the log file path and that its parent directory exists and is writable
- Check no other process holds the file locked; stop competing writers
- Use a valid absolute VFS-compatible filename
- Run the process under a user with write permissions to the target
Example fix
// before
new LogChannelFileWriter("/nonexistent/dir/run.log", false);
// after
new File("/var/log/kettle").mkdirs();
new LogChannelFileWriter("file:///var/log/kettle/run.log", false); Defensive patterns
Strategy: validation
Validate before calling
// Check writability of the log file location before constructing the writer
File logFile = new File(logPath);
File parent = logFile.getAbsoluteFile().getParentFile();
if (parent == null || !parent.isDirectory()) throw new IllegalStateException("Log dir missing: " + parent);
if (logFile.exists() && !logFile.canWrite()) throw new IllegalStateException("Log file not writable: " + logFile); Type guard
static boolean isWritableLogFile(String path) {
File f = new File(path);
return (f.getParentFile() == null || f.getParentFile().canWrite())
&& (!f.exists() || f.canWrite());
} Try / catch
try {
writer = new LogChannelFileWriter(logChannelId, logFile, appending);
} catch (KettleException e) {
if (e.getMessage().contains("for writing")) {
log.error("Cannot open log file " + logFile + ": ", e.getCause());
} else throw e;
} Prevention
- Validate the log filename/directory in transformation/job settings before execution
- Use absolute paths and create parent directories first
- Ensure only one process writes to the same log file
When it happens
Trigger: Constructing LogChannelFileWriter with a logFile path that is in a non-existent directory, without write permission, locked by another process, or an invalid VFS URI.
Common situations: Misconfigured log filename in transformation/job settings; read-only output directory; file held open by another running transformation; bad path scheme (e.g. missing file: prefix).
Understand the failure class
Background: "open() failed", "failed to open file", "cannot create file" — what a file open error means and how to fix it — this error's family across 42 libraries.
Related errors
- Unable to create a logging event listener to write to file
- AbstractFileErrorHandler.Exception.CouldNotCreateFileErrorHandlerForFile
- AvroInputDialog.Error.KettleFileException
- ERROR_0001_TARGET_EXISTS
- Error opening file [" + data.filename + "]!
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/083f08147dc6a5c0.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/core/logging/LogChannelFileWriter.java:74
* @param pollingInterval
* The polling interval in milliseconds.
*
* @throws KettleException
* in case the specified log file can't be created.
*/
public LogChannelFileWriter( String logChannelId, FileObject logFile, boolean appending, int pollingInterval ) throws KettleException {
this.logChannelId = logChannelId;
this.logFile = logFile;
this.appending = appending;
this.pollingInterval = pollingInterval;
active = new AtomicBoolean( false );
finished = new AtomicBoolean( false );
try {
logFileOutputStream = KettleVFS.getInstance( DefaultBowl.getInstance() ).getOutputStream( logFile, appending );
} catch ( IOException e ) {
throw new KettleException( "There was an error while trying to open file '" + logFile + "' for writing", e );
}
this.buffer = new LogChannelFileWriterBuffer( this.logChannelId );
LoggingRegistry.getInstance().registerLogChannelFileWriterBuffer( this.buffer );
}
/**
* Create a new log channel file writer
*
* @param logChannelId
* The log channel (+children) to write to the log file
* @param logFile
* The logging file to write to
* @param appending
* set to true if you want to append to an existing file
*
* @throws KettleException
* in case the specified log file can't be created.View on GitHub (pinned to f3058517a1)