這可能是顯而易見的,但我一直在尋找使用org.apache.commons.logging
一個簡單的例子來登錄到特定的文件(即/path/to/my-log.txt
)如何使用org.apache.commons.logging登錄到文件?
public class MyClass {
static Log log = LogFactory.getLog(MyClass.class);
public static void main(String[] args) {
// What to do here to get log to output to a file???
log.info("I want to appear in a specific log file")
}
}
這只是spitballing,但也許建立了一個虛擬的類記錄,並做'靜態登錄日誌= LogFactory.getLog(ThatOtherClass.class);' – corsiKa 2013-03-08 01:16:26
我正在嘗試將輸出寫入一個我可以指定的文件。因此,log.info中的消息將出現在特定文件(即/path/to/my-log.txt)中 – chaimp 2013-03-08 01:19:59
當您說明指定時,是否指的是從程序中動態指定? – corsiKa 2013-03-08 01:28:00