// create a java.util.logging.Logger // now java.util.logging.Logger should be created for each platform // logger
Logger logger = Logger.getLogger("test.log.bar");
logger.log(Level.SEVERE, "Log message {0} {1}", params);
privatestaticvoid checkLogRecords(File log) throws Exception {
System.out.println("Checking log records in file: " + log);
FileInputStream in = new FileInputStream(log);
String EXPECTED_LOG = "SEVERE: Log message 1 string"; try {
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String line;
String[] record = new String[2]; int count = 0; int i = 0; while ((line = reader.readLine()) != null) {
line = line.trim();
System.out.println(line);
record[i++] = line; if (i == 2) {
i = 0; // check log message if (!record[1].equals(EXPECTED_LOG)) { // it can sometime happen that some static initializer // in the system will log an error message - due to e.g. // some kind of misconfiguration or system settings. // For instance - somethink like: // INFO: currency.properties entry for FR ignored // because the value format is not recognized. // instead of failing if we get such an unexpected // message, we will simply print that out.
System.out.println("*** WARNING: Unexpected log: " + record[1]); continue;
}
count++; // check source class name and method
String[] ss = record[0].split("\\s+"); int len = ss.length; if (!ss[len-2].equals("SourceClassName") ||
!ss[len-1].equals("writeLogRecords")) { thrownew RuntimeException("Unexpected source: " +
ss[len-2] + " " + ss[len-1]);
}
}
} if (count != 3) { thrownew RuntimeException("Unexpected number of records: " + count);
}
} finally {
in.close();
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.