views:

27

answers:

2

I want to include a log4j into the package generated by mvn assembly:assembly so that log4j is configured when the generated .jar is executed. How do I do this?

My assembly plugin looks like this:

  <plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
      <archive>
        <manifest>
          <mainClass>ibis.structure.Structure</mainClass>
        </manifest>
      </archive>
      <descriptorRefs>
        <descriptorRef>jar-with-dependencies</descriptorRef>
      </descriptorRefs>
    </configuration>
  </plugin>
+1  A: 

I want to include a log4j into the package generated by mvn assembly:assembly so that log4j is configured when the generated .jar is executed. How do I do this?

I don't understand the problem. Put the log4j.properties under src/main/resources and it will be packaged in your jar (and then end up in the assembly). Is there any problem with that?

Pascal Thivent
A: 

I wouldn't recommend packaging log4j descriptor into a jar otherwise you can't change any log level without repackaging, which could be a pain. Better externalizing your log4j.properties into a directory on your file system that you include in the classpath.

Damien