File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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){
Context ctx = new InitialContext();
logger = Logger.getLogger(appClassName);
FileHandler handler = null;
if (fileLogging){
handler = (FileHandler) ctx.lookup("AppSoapMsgFileHandler");
} else {
handler = (FileHandler) ctx.lookup("AppFileHandler");
} catch(NamingException ne){"NamingException occured while looking up AppFileHandler/AppSoapMsgFileHandler: "+ne.getMessage());
public void configLogger(String logMsg){
public void infoLogger(String logMsg){;
public void warningLogger(String logMsg){
public void severeLogger(String 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:
subject: java.util.logging.Logger: outputs multiple similar lines
It's not a secret anymore!