dcsimg
java.util.logging behavior
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Alan_Honczar
Posted On:   Friday, November 1, 2002 07:53 AM

I am using Java 1.4.0 Logging API. Logging to a file using a FileHandler made my app log to my file, but the app is still logging to standard output... (In tomcat logging in catalina.out) Do anyone know any way to avoid that? part of code: logger = Logger.getLogger("defaultLog"); FileHandler fh = null; logger.log(Level.INFO, "Initializing LogGate."); Properties p = new Properties(); try { //get path String realPath = System.getProperty("app.path"); //System.getProperties(log.path); logger.log(Level.INFO,"app.path = "+realPath);    More>>


I am using Java 1.4.0 Logging API.



Logging to a file using a FileHandler made my app log to my file,



but the app is still logging to standard output...



(In tomcat logging in catalina.out)



Do anyone know any way to avoid that?


part of code:



logger = Logger.getLogger("defaultLog");
FileHandler fh = null;
logger.log(Level.INFO, "Initializing LogGate.");
Properties p = new Properties();
try {
//get path
String realPath = System.getProperty("app.path"); //System.getProperties(log.path);
logger.log(Level.INFO,"app.path = "+realPath);
if(realPath==null){
logger.log(Level.SEVERE,"Apps path must be set. Set log.properties.path as a JVM property.");
}else{
p.load(new FileInputStream(realPath+"/cfg/log.properties"));
String filename = (String) p.get("log.filename");
String limit = (String) p.get("log.limit");
String count = (String) p.get("log.count");
String level = (String) p.get("log.level");

String dateFormat = (String) p.get("log.date.format");
String className = (String) p.get("log.class.name");
String method = (String) p.get("log.method.name");
String threadId = (String) p.get("log.thread.id");
String dateTime = (String) p.get("log.dateTime");
String ipadd = (String) p.get("log.ip.address");
String logPath = (String) p.get("alternate.log.path");

if(logPath!=null&&logPath.length()>0){
fh = new FileHandler(logPath+"/"+filename+"%ur%g.log",Integer.parseInt(limit),Integer.parseInt(count),true);
}else{
fh = new FileHandler(realPath+"/log/"+filename+"%ur%g.log",Integer.parseInt(limit),Integer.parseInt(count),true);
}
fh.setLevel(Level.parse(level.trim()));
fh.setFormatter(new LogFormatter("true".equals(ipadd)?true:false,
"true".equals(dateTime)?true:false,
"true".equals(threadId)?true:false,
"true".equals(className)?true:false,
"true".equals(method)?true:false,
dateFormat));
logger.getAnonymousLogger().setLevel(Level.OFF);
logger.addHandler(fh);
logger.log(Level.INFO,"LogGate initialized.");

}
}catch (FileNotFoundException f) {
logger.log(Level.SEVERE, "Properties file not found. LogGate NOT initialized.", f);
}catch (IOException e) {
logger.log(Level.SEVERE, "Error reading properties file. LogGate NOT initialized.", e);
}

   <<Less
About | Sitemap | Contact