我想寫一些測試消息或一些文本內容通過java inbiz框架文件。如果文件已經有內容,則最近的消息必須附加在文件的底部。如何寫文本或登錄到ofbiz框架中的文件
簡而言之,我想要一個諸如ofbiz中Debug.log的功能。由於它將所有內容寫入debug.log文件,因此我需要一個單獨的文件來編寫我的文本消息。
我想這一點,
File file = new File("/applications/party/webapp/partymgr/test.txt");
if (!file.exists()) {
try {
file.createNewFile();
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
Debug.logInfo("writing...........", module);
bw.write("this is first line in file");
bw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
但它扔FileNotFoundException
。
因爲,我不是在ofbiz的專家,我不確定文件路徑。如果文件路徑是問題,請提出解決方案。
獲取相對路徑你爲什麼不只需添加一個新的RollingFileAppender進行在log4j配置?如果你想把自己的perf數據寫到它自己的日誌文件中,你會這樣做...... – arajashe
我已經看到了,但我無法理解這種機制。你能否以更詳細的方式說出或給我任何幫助的教程。謝謝@arajashe –