0

我有一个属性文件记录器怎么做,以便我可以将它用于不同的类,但它们有不同的名称?就我而言,对于不同的类将使用相同的名称进行记录。

这是我的文件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.");
4

0 回答 0