Friday, June 24, 2011

How adding log4j in or application Spring3 Maven JBoss6 ?

For adding log4j with Maven, the first things that you want to do is :
<dependency>
  <groupId>log4j</groupId>
  <artifactId>log4j</artifactId>
  <version>1.2.15</version>
</dependency>

You can't because of licensing issue of some fonctionnality in log4j.
I've found the explanation on http://unitstep.net/blog/2009/05/18/resolving-log4j-1215-dependency-problems-in-maven-using-exclusions/ :

If you’re using Maven to manage your project’s build and dependencies, you may have encountered some problems when trying to include the latest version of log4j as a dependency.
 Specifically, log4j 1.2.15 depends on some artifacts that are not available in the central Maven repository due to licensing issues, and thus when you try to build a project that depends on this version of log4j,
 you may not be able to download the artifacts and your build will fail.

So you have to do the following :
   <dependency>
     <groupId>log4j</groupId>
     <artifactId>log4j</artifactId>
     <version>1.2.15</version>
     <exclusions>
       <exclusion>
         <groupId>javax.mail</groupId>
         <artifactId>mail</artifactId>
       </exclusion>
       <exclusion>
         <groupId>javax.jms</groupId>
         <artifactId>jms</artifactId>
       </exclusion>
       <exclusion>
         <groupId>com.sun.jdmk</groupId>
         <artifactId>jmxtools</artifactId>
       </exclusion>
       <exclusion>
         <groupId>com.sun.jmx</groupId>
         <artifactId>jmxri</artifactId>
       </exclusion>
     </exclusions>
   </dependency>


I've add log4j dependency on the trunk of my tutorial google project with Spring Maven et JBoss 6.0.0 : http://code.google.com/p/lin-mon-webapp/



references :
http://unitstep.net/blog/2009/05/18/resolving-log4j-1215-dependency-problems-in-maven-using-exclusions/

No comments:

Post a Comment