如何将logging.properties用于不同的clases?

时间:2013-05-28 20:03:43

标签: java java.util.logging

我有一个属性文件记录器如何操作,以便我可以将它用于不同的类,但它们有不同的名称? 就我而言,对于不同的类,将使用相同名称的记录器。

这是我的文件 logging.properties

handlers = java.util.logging.FileHandler
java.util.logging.FileHandler.pattern = C:\\\temp\\\application_log.txt 
java.util.logging.FileHandler.limit = 1048576
java.util.logging.FileHandler.count = 5
java.util.logging.FileHandler.formatter =
java.util.logging.XMLFormatter

以下是我尝试加载数据的代码:

try {
  LogManager.getLogManager (). ReadConfiguration (
  MyClawlerFrame.class.getResourceAsStream ("logging.properties"));
} Catch (IOException ex) {
  System.out.println ("Could not create file. Using the console handler");
  logger.info ("Could not create file. Using the console handler");
  handler = new ConsoleHandler ();
}

logger.info ("Application started.");

0 个答案:

没有答案
相关问题