簡體   English   中英

如何停止在控制台上打印log4j FileNotFound錯誤?

[英]How to stop printing log4j FileNotFound Error on console?

我創建了一個實用程序,用於將一些文本數據移動到SQL數據庫中,並已實現了用於調試目的的logging(log4j)。 一旦創建了一個我的實用程序的jar並調用它來執行,該實用程序就可以正常工作,但是每次輸出之前都會出現以下錯誤消息:

log4j:ERROR Could not read configuration file [log4j.properties].
java.io.FileNotFoundException: log4j.properties (The system cannot find the file specified)
        at java.io.FileInputStream.open0(Native Method)
        at java.io.FileInputStream.open(Unknown Source)
        at java.io.FileInputStream.<init>(Unknown Source)
        at java.io.FileInputStream.<init>(Unknown Source)
        at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:306)
        at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:324)
        at spotfire.loadtest.Driver.main(Driver.java:28)
log4j:ERROR Ignoring configuration file [log4j.properties].
log4j:WARN No appenders could be found for logger (spotfire.loadtest.Driver).
log4j:WARN Please initialize the log4j system properly.

請注意,我的實用程序有效,並且文本已插入數據庫中。 我面臨的唯一問題是如何擺脫此錯誤消息。 有什么辦法可以完全停止打印?

您的log4j.properties必須位於類路徑中,或者需要將其指定為JVM Argument as

-Dlog4j.configuration = {文件路徑}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM