if the log pattern/path referenced doesn't exist, create all necessary parent directories (killing the JVM if it fails, rather than silently gobble the log messages to /dev/null)
This commit is contained in:
@ -122,6 +122,18 @@ class LogWriter implements Runnable {
|
||||
File f = getNextFile(pattern);
|
||||
_currentFile = f;
|
||||
_numBytesInCurrentFile = 0;
|
||||
File parent = f.getParentFile();
|
||||
if (!parent.exists()) {
|
||||
boolean ok = parent.mkdirs();
|
||||
if (!ok) {
|
||||
System.err.println("Unable to create the parent directy: " + parent.getAbsolutePath());
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
if (!parent.isDirectory()) {
|
||||
System.err.println("wtf, we cannot put the logs in a subdirectory of a plain file! we want to stre the log as " + f.getAbsolutePath());
|
||||
System.exit(0);
|
||||
}
|
||||
try {
|
||||
_currentOut = new FileOutputStream(f);
|
||||
} catch (IOException ioe) {
|
||||
|
Reference in New Issue
Block a user