我在一个java程序中使用了log4j。我初始化它:
BasicConfigurator.configure(); // logger configuration
try {
logger.setLevel(Level.DEBUG);
} catch (Exception e) {
System.out.println("Logfile not found");
}
但是,在程序执行期间,我得到 3 个日志语句而不是 1 个。例如,
3 lines
1047 [main] INFO ibis.Preproc.Ratings - Added AS TIMEZONE to tZones[0] = GMT-12:00
1047 [main] INFO ibis.Preproc.Ratings - Added AS TIMEZONE to tZones[0] = GMT-12:00
1047 [main] INFO ibis.Preproc.Ratings - Added AS TIMEZONE to tZones[0] = GMT-12:00
而不是一行
1047 [main] INFO ibis.Preproc.Ratings - Added AS TIMEZONE to tZones[0] = GMT-12:00
是否需要对 log4j 进行任何额外的配置来避免这种情况?