1 2 Previous Next 19 Replies Latest reply on Apr 20, 2012 5:24 PM by apodgorsek Go to original post
      • 15. Re: Log4j properties file not working
        apodgorsek

        Thanks for input.

         

        I've tried the following:

         

        - moved deployment-structure.xml up to ear, and upped the pom version to 2.7 as you wrote

        - added log4j as compile/jar to both ear and war project (also with deployment-struct.xml)

        - added log4j as compile/jar to ear and provided/jar to both ejb and war project (also with deployment-struct.xml)

         

        Still it doesn't print out to desired log file.

         

        I've attached the latest project sample

        • 16. Re: Log4j properties file not working
          sfcoy

          Ok. It seems that the jboss-deployment-structure.xml file in the EAR must contain:

          {code:xml}

          <?xml version="1.0" encoding="UTF-8"?>

          <jboss-deployment-structure>

              <deployment>

                  <exclusions>

                      <module name="org.apache.log4j" />

                  </exclusions>

              </deployment>

              <sub-deployment name="Test-ejb-0.0.1-SNAPSHOT.jar">

                  <exclusions>

                      <module name="org.apache.log4j" />

                  </exclusions>

              </sub-deployment>

              <sub-deployment name="Test-web-0.0.1-SNAPSHOT.war">

                  <exclusions>

                      <module name="org.apache.log4j" />

                  </exclusions>

              </sub-deployment>   

          </jboss-deployment-structure>

          {code}

           

          I suspect that you can remove the WAR sub-deployment element above if you leave the existing jboss-deployment-structure.xml file in the WAR file, but I did not try that.

           

          I used only the above jboss-deployment-structure.xml in the EAR and removed the one you had in the last EAR and it worked for me.

           

          Also, I see that you changed the log4j dependencies in the EJB and WAR projects to scope "provided". This is not necessary as the maven-ear-plugin figures all this stuff out correctly these days.

          • 17. Re: Log4j properties file not working
            apodgorsek

            Thank you Stephen, I really appriciate your answer.

             

            There is one thing I noticed, and it is that -ejb package doesn't get logged in the file specified in log4j properties. Do you maybe know why? I suspect it i because I only initialize log4j properties from external file in the -web module and somehow it doesn't affect the -ejb module although category is set so, that It should be avail in both. (on other app servers this works)

            • 18. Re: Log4j properties file not working
              sfcoy

              The modified example that I attached to my previous example works for me.

               

              If I use the "Register" button, I get

              11:11:45,740 INFO  [MemberRegistration] Registering Fred

              in the log file.

               

              If it's not working for you, this indicates that there is still a copy of the log4j.jar in your webapp.

               

              Note that I'm testing without an IDE at this point.

              • 19. Re: Log4j properties file not working
                apodgorsek

                Yes it works as you said. It is needed to say that in JBDS 5 beta 1, logging doesn't work from ejb...don't know why, guess it's some IDE/JBoss Tools quirk. Where do I open this issue?

                 

                Thank you again!

                1 2 Previous Next