I m using some code to create dir if it does not exist, in my own appender
If someone can put it in setFile() in log4j code, it would be great!
ks
public void createDirs(String fileName) {
try {
File f = new File(fileName);
String dir = f.getCanonicalPath();
System.out.println("log4j log is here "+dir);
int lastSlash = 0;
if (dir != null) {
lastSlash = dir.lastIndexOf(File.separator);
if (lastSlash != -1) {
dir = dir.substring(0, lastSlash);
File directory = new File(dir);
directory.mkdirs();//vow
}
}
throw new Exception("To find where I am !! ");
} catch (Exception e) {
e.printStackTrace();//ignore
}
}