开发者

J2EE and Standard Java Application Log4j.properties

I have a project folder with merged J2ee application and standard java application. I am having trouble with configuring the Log4j.properties. I want to have separate log files 1 for my web application and another 1 for my standard application. I have two Log4j.properties files one under the root package of my web application and one under the root package of my standard application where both packages are under src folder. When I ran both web app and standard app specifying only the file name, the log file for my webapp is created in the web server directory but my standard java app log file is created inside my WAR directory. I want the log file for my standard java app and my web app to be placed in the root folder that is why I specified in both log4j.properties absolute path开发者_StackOverflow社区 to that folder. The problem is the only created log file depends on which log4j.properties file was detected and logs for both my web app and standard java app was written on that one file


This will be a detective work since I'll have more questions than you did.

I have a project folder with merged J2ee application and standard java application

This distinction seems to me a bit blurry. You have one project folder for two applications? It would be easier if they were separated. Is your standard java application a standalone application that can be run on a command line? A set of utility classes like a library?

I want to have separate log files 1 for my web application and another 1 for my standard application

I believe here lies your problem. If you're using your standard application's libraries in your web app, then during loading the application server will find two log4j.properties files on the classpath. You can not be sure 100% how this will behave.

When I ran both web app and standard app specifying only the file name, the log file for my webapp is created in the web server directory but my standard java app log file is created inside my WAR directory.

Running a web app specifying only the file name is unclear. What file name? When you say your WAR directory, do you mean the directory of your webapp, that's also inside your web server directory, or the directory under your (I'll assume you use Eclipse) IDE's project folder?

I want the log file for my standard java app and my web app to be placed in the root folder that is why I specified in both log4j.properties absolute path to that folder.

Root folder, like / in *nix? If you want them both to be placed in one folder, then you should remove one of log4j.properties files.

The problem is the only created log file depends on which log4j.properties file was detected and logs for both my web app and standard java app was written on that one file

Yes. You need to have only one log4j.properties file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜