我使用log4j登錄我的應用程序。在每堂課我需要登錄的東西我有以下幾點:Log4j沒有看到.properties文件
Properties props = new Properties();
try {
props.load(new FileInputStream("/log4j.properties"));
} catch (Exception e){
LOG.error(e);
}
PropertyConfigurator.configure(props);
log4j.properties放置到該文件夾/ src目錄/主/資源/
路徑/log4.properties由IDEA給出複製參考。當我啓動我的應用程序時,它顯示FileNotFoundException
不要使用'FileInputStream',用你的'類#的getResourceAsStream()',因爲該文件是在classpath。你也不需要自己加載log4j屬性。 –
如果我自己不加載log4j.properties,我會得到類似「log4j no config found。正確配置log4j」 –
你在哪裏放置該文件? –