+ 3

How to create log4j file outside of jar using cmd?

I created one console App in Eclipse Mars and It is working fine in Eclipse. If I do export jar of this project and execute through CMD then it is also working except log4j. So problem is log file is not creating outside of Jar. I have one solution that we can pass jvm argument like -Dlog4j.configuration=file:"/path" and getting log file. but I want to create log file without passing jvm argument. So Is there any alternative Solution?

21st Dec 2016, 5:57 AM
Piyush Gupta
Piyush Gupta - avatar
7 Réponses
+ 3
Eres In IDE it will work fine but if you call jar file then log file will not create because it will not find any appenders for logger and threw WARN meassage like... Please initialize the log4j system properly
21st Dec 2016, 7:06 AM
Piyush Gupta
Piyush Gupta - avatar
+ 2
Eres, If I set -Dlog4j.configuratorClass then how will be change path of log file dynamically?
21st Dec 2016, 6:40 AM
Piyush Gupta
Piyush Gupta - avatar
0
-Dlog4j.configuratorClass=com.foo.BarConfigurator
21st Dec 2016, 6:38 AM
Eremie Gillowei
Eremie Gillowei - avatar
0
You can also use a configuration class instead of the properties or xml file.👆
21st Dec 2016, 6:38 AM
Eremie Gillowei
Eremie Gillowei - avatar
0
The log files are not generated inside the logs folder which is under your project root folder right???
21st Dec 2016, 6:45 AM
Eremie Gillowei
Eremie Gillowei - avatar
0
Have you tried putting it simply in the same folder as api.jar instead of inside the jar?
21st Dec 2016, 7:41 AM
Eremie Gillowei
Eremie Gillowei - avatar
- 1
Hello everyone, I have a plan to learn java but a moment ago I found out that there is a vulnerability that has been detected and many malicious hackers are exploiting me, be careful! 🌋🌋🌋😫
21st Dec 2021, 10:42 PM
Edwin Silvestre PRO
Edwin Silvestre PRO - avatar