You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by shy guy <sh...@gmail.com> on 2005/11/01 17:42:38 UTC

Re: Cross-platform File appender paths?

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
}
}