import java.net.URL;
public class LogFileNamer {
- public static final int pid = PIDAccess.INSTANCE.getpid();
public final String root;
- private boolean printPID;
public LogFileNamer(String root) {
if(root==null || "".equals(root) || root.endsWith("/")) {
} else {
this.root = root + "-";
}
- printPID=true;
}
public LogFileNamer noPID() {
- printPID = false;
return this;
}
/**
String rv;
System.setProperty(
"LOG4J_FILENAME_"+(rv=appender.substring(0,pipe)),
- root + appender.substring(pipe+1) + (printPID?('-' + pid):"") + ".log");
+ root + appender.substring(pipe+1) + ".log");
return rv;
} else {
System.setProperty(
"LOG4J_FILENAME_"+appender,
- root + appender + (printPID?('-' + pid):"") + ".log");
+ root + appender + ".log");
return appender;
}
public void configure(String props) {
String fname;
if(new File(fname="etc/"+props).exists()) {
- org.apache.log4j.PropertyConfigurator.configureAndWatch(fname,60*1000);
+ org.apache.log4j.PropertyConfigurator.configureAndWatch(fname,60*1000L);
} else {
URL rsrc = ClassLoader.getSystemResource(props);
if(rsrc==null) System.err.println("Neither File: " + fname + " or resource on Classpath " + props + " exist" );