• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question about java logging.

 
zb cong
Ranch Hand
Posts: 416
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello:

my code as follow:

LogManager lm = LogManager.getLogManager();
lm.readConfiguration(NewClass.class.getResourceAsStream("mylog.properties"));
System.out.println(lm.getProperty("handlers"));
Logger logger1 = lm.getLogger("");
System.out.println(logger1);
Logger logger2 = lm.getLogger("com.mycompany");
System.out.println(logger2);


and the mylog.properties file as following;

# Logging
handlers = java.util.logging.FileHandler
# File Logging
java.util.logging.FileHandler.pattern = c:/myApp.log
java.util.logging.FileHandler.append = true
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.FileHandler.level = INFO
# Console Logging
java.util.logging.ConsoleHandler.level = ALL
com.mycompany.level = ALL


when it is executed, the logger1 is printed as root logger, but the logger2 is null, how can i get logger2 which is configured in the mylog.properties?

Thanks very much...
 
Campbell Ritchie
Sheriff
Pie
Posts: 49364
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Too difficult a question for "beginning". Moving thread.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic