プロパティ ファイル ロガーを別のクラスに使用できるようにする方法がありますが、それらは別の名前でしたか? 私の場合、異なるクラスは同じ名前でロガーします。
これが私のファイル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.");