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
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