This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Steve Watson
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!