search

Home  >  Q&A  >  body text

java - 本地能打出日志 但是打成jar包到服务器上 就不产生日志了?

PropertyConfigurator.configure("src/main/resources/log4j.properties");

是因为 打成jar包了 所以不识别这个路径吗????

PHPzPHPz2911 days ago636

reply all(1)I'll reply

  • 迷茫

    迷茫2017-04-18 10:31:52

    Have you built a Maven project? If so, it is correct to place log4j.properties in the src/main/resources directory. Reading and log printing records are no problem, but there is a problem with your reading path. The correct way to write it is It is "PropertyConfigurator.configure("log4j.properties");". For problems that do not generate logs, please do the following checks:
    1. If the local setting is ConsoleAppender (console printing), change it to DailyRollingFileAppender (write to the specified log file);
    2. Check whether the path of the log file output is changed and correct.

    Of course, it’s best to paste the content of log4j.properties and take a look

    reply
    0
  • Cancelreply