public void setOption(String key,
String value) {
super.setOption(key, value);
if(key.equalsIgnoreCase(PATH_OPTION)) {
path = value;
if(path==null) {
errorHandler.error("Path cannot be empty!",null,0);
}
dir = new File(path);
if(!(dir.exists() && dir.isDirectory() && dir.canWrite())) {
errorHandler.error("Cannot write to directory " + path + "!",null,0);
}
}
else if(key.equalsIgnoreCase(PREFIX_OPTION)) {
if(value!=null && value.length() >=3) {
prefix = value;
} else {
errorHandler.error("Prefix cannot be shorter than 3 characters!",
null,0);
}
}
else if(key.equalsIgnoreCase(SUFFIX_OPTION)) {
if(value!=null && value.length() >=1) {
suffix = value;
} else {
errorHandler.error("Suffix cannot be empty!",null,0);
}
}
}
|
protected void subAppend(LoggingEvent event) {
try {
File tmp = File.createTempFile(prefix,suffix,dir);
Writer out = new BufferedWriter(new FileWriter(tmp));
out.write(event.message);
out.close();
/* this Appender is not supposed to be used for logging of Exceptions */
} catch (Exception e) {
errorHandler.error("Error during creation of temporary File!",e,1);
}
}
This method does actual writing |