aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes java.util.logging.Logger: outputs multiple similar lines Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "java.util.logging.Logger: outputs multiple similar lines " Watch "java.util.logging.Logger: outputs multiple similar lines " New topic
Author

java.util.logging.Logger: outputs multiple similar lines

Steve Watson
Ranch Hand

Joined: Apr 08, 2003
Posts: 38
Using the new (In jdk 1.4) Logging API, we find that the same message is output to the log multiple times - does anyone know the solution to this?
We have a Logging class that includes:
public class AppLogger{
private Logger logger = null;
public AppLogger(String appClassName, boolean fileLogging){
try{
Context ctx = new InitialContext();
logger = Logger.getLogger(appClassName);
FileHandler handler = null;
if (fileLogging){
handler = (FileHandler) ctx.lookup("AppSoapMsgFileHandler");
} else {
handler = (FileHandler) ctx.lookup("AppFileHandler");
}
logger.addHandler(handler);
logger.setLevel(handler.getLevel());
} catch(NamingException ne){
WLSLogger.info("NamingException occured while looking up AppFileHandler/AppSoapMsgFileHandler: "+ne.getMessage());
}
}
public void configLogger(String logMsg){
logger.config(logMsg);
}
public void infoLogger(String logMsg){
logger.info(logMsg);
}
public void warningLogger(String logMsg){
logger.warning(logMsg);
}
public void severeLogger(String logMsg){
logger.severe(logMsg);
}
Then individual classes invoke logging by instatiating the AppLogger and calling its methods:
private AppLogger logger = new AppLogger(this.getClass().getName(),false);
logger.infoLogger("Hello World");
I appreciate any help.
Steve Watson
Steve Watson
Ranch Hand

Joined: Apr 08, 2003
Posts: 38
I found a solution - in case anyone reads this thread I will answer my own problem. Basically need to control instances of the logging class - made it into a Singleton.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.util.logging.Logger: outputs multiple similar lines
 
Similar Threads
log4j in jboss
Help needed on File logging
Java 5 logging in JSPs and Tomcat
Writing logs to a single file from Multiple Classes
java.util.Logger creating multiple log files