Enable JCL in Toolkit project Requirements:
- Regulate warning level (we shoud be able to suppress logs eg LEVEL.OFF)
- Component loggin enablement (eg. Log SQL Statements, Login History, Mail Disribution)
Questions we have:
- Where do we keep properties for this feature ?
- How do we change properties for Logger module ?
Proposed solutions:
- JCL implementation by LOG4J (Logger.debug)
- plus
- well known standards
- more levels than just out and err - ALL, OFF, DEBUG, ERROR, FATAL, INFO, WARN
- minus
- need code in the init servlet, a thread to check for properties updates is created
- need access to properties file - to edit and change settings, maybe manual pushes of updated properties files
- JCL implementation By WS5.0 (System.out, System.err)
- plus
- Administration console already exists
- minus
- Limitied functionality
import org.apache.log4j.*;
import org.apache.log4j.net.SMTPAppender;
import org.apache.log4j.net.SyslogAppender;
import org.apache.log4j.Logger;
import java.util.Properties;
import java.io.*;
public class Test {
private static Properties props = new Properties();
static {
try {
props.load(new FileInputStream("c:/log4j.properties"));
// PropertyConfigurator.configure(props);
PropertyConfigurator.configureAndWatch("c:/log4j.properties", 20 * 1000);
} catch(IOException e) {
e.printStackTrace(System.err);
}
}
Test() {
while (true) {
Logger.getRootLogger().debug("test1");
// switchAppenders2("A2");
Logger.getRootLogger().debug("test2");
}
}
public static void main(String args[]) {
Test t = new Test();
}
private static void switchAppenders() {
try {
props.load(new FileInputStream("c:/log4j1.properties"));
PropertyConfigurator.configure(props);
} catch(IOException e) {
e.printStackTrace(System.err);
}
}
private static void switchAppenders2(String appenderName) {
props.put("log4j.rootLogger", "DEBUG," + appenderName);
PropertyConfigurator.configure(props);
}
private static void switchLevel(org.apache.log4j.Level level) {
}
}
