Creating log4j (logging) for a EJB\WEB project
If we have a big project with both Web and EJB projects and a EAR project to link them and if we want to implement logging, in this case here is the approval we need to take.
In the EAR project, under META-INF folder, we need to create a folder called "APP-INF" under this folder, we need to place the log4j.jar file.
Once we add the jar file, we need to include a reference to this jar file from Web and EJB project.
Right click on the project "OCEDecisionEJB" and "OCEDecisionWeb", properties, Java build path, Libraries tab, click "Add JARs" button and select the log4j.jar from EAR project.
As we can see in the snapshot, the log4j.jar in the EJB project refers to the EAR project. (OCEDecisionEAR/META-INF/APP-INF).
Once this is done, we need to open the META-INF\MANIFEST.MF file in both EJB and WEB projects. For Web project it should be under WebContent\META-INF\MANIFEST.MF
MANIFEST.MF = This is basically a "Jar Dependency Editor". We edit this file and add
this line.
Class-Path: META-INF/APP-INF/log4j.jar
This means add the log4j jar file in the classpath.
Once this done, we can verify the details by right click on EJB and Web projects, "J2EE Module Dependencies". We can see the dependency defined here.
0 Comments:
Post a Comment
<< Home