facebook

Configuring Log4J in an EAR Project

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #203309 Reply

    I am porting our existing commercial EAR application (FVM) to MyEclipse. I created a new EAR project. So I have top level directories XFVM, XFVMEJB and XFVMWeb.

    I want to add log4j-1.2.8.jar to the project. I would like it to end up in the EAR at the top level with a Manifest entry for Class-Path in the EJB jar and the Web war pointing to log4j jar.

    Also I need to put log4j.properties somewhere.

    What is your recommended approach?

    #203315 Reply

    I put Class-Path: log4j.1.2.8.jar into MANIFEST.MF in XFVMEJB\src\META-INF and XFVMWeb\WebRoot\META-INF. I put log4j.1.2.8.jar into the \XFVM folder. Built all and deployed to JBoss 3.2.3. Everything seems to be in the right place.

    I’ll try putting log4j.properties into \XFVM along with the log4j jar. I have some other app properties issues to resolve in connection with my port, so I won’t have a chance to test log4j logging at runtime for a while yet.

    -David

    #203316 Reply

    Scott Anderson
    Participant

    David,

    It sounds like you’ve already started down the path I would’ve recommended. All you have to do is bear in mind that our project layouts are exactly like an exploded EAR/WAR/EJB jar. So, if you place each of your artifacts in the same place you would in your archived distribution, it should work just fine. And, that sounds like what you’re up to, so please let us know how it goes and if you run into any sticking points.

    #203433 Reply

    Scott,

    Well, it turns out that JBoss 3.x comes bundled with Log4J 1.2.x. So it’s not necessary to include log4j-1.2.8.jar in the XFVM EAR, nor to point to it via manifest files.

    So a better question would have been how to bundle Log4J into an EAR for an app server that doesn’t already integrate it, like OC4J. Anyway, the technique outlined above will work for OC4J, assuming you enable scanning of manifest files in WAR archives, a special option in OC4J 9.0.x.

    The only remaining question is where to locate log4j.properties. JBoss puts it in the \conf directory of the server configuration set you are running. Then it accesses it from the Log4J configuration MBean like so:

    <attribute name=”ConfigurationURL”>resource:log4j.xml</attribute>

    I’m not sure why this URL magically resolves to the server home \conf directory. Anyone have an explanation?

    For OC4J, if you locate log4j.properties in the server’s \applib directory, it will be on the application classpath, and Log4J will initialize itself as soon as any Logger class instance is loaded.

    But it would be nice if you could put the log4j.properties file in the server’s \config directory and intialize it explicitly when your application starts up using a resource URL like JBoss does. I would be interested if anyone has a working example of this for OC4J, Orion or Oracle 9iAS.

    -David

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: Configuring Log4J in an EAR Project

You must be logged in to post in the forum log in