maven - different log4j.xml when exporting jar from eclipse -
i have problem when export executable jar.
i'm using maven , slf4j log4j
my pom.xml
<dependency> <groupid>org.slf4j</groupid> <artifactid>slf4j-log4j12</artifactid> <version>1.7.2</version> <scope>runtime</scope> </dependency>
i added log4j.xml in /src/java/main (is same in generated target folder):
<?xml version="1.0" encoding="utf-8" ?> <!doctype log4j:configuration system "log4j.dtd"> <log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'> <appender name="file" class="org.apache.log4j.rollingfileappender"> <param name="file" value="/media/dlm/log/dlm.log" /> <param name="threshold" value="info" /> <param name="append" value="false" /> <param name="maxfilesize" value="10mb" /> <param name="maxbackupindex" value="1" /> <layout class="org.apache.log4j.patternlayout"> <param name="conversionpattern" value="%d{absolute} %-5p [%c{1}:%l] %m %n" /> </layout> </appender> <appender name="console" class="org.apache.log4j.consoleappender"> <param name="target" value="system.out" /> <param name="threshold" value="info" /> <layout class="org.apache.log4j.patternlayout"> <param name="conversionpattern" value="%d{absolute} %-5p [%c{1}:%l] %m %n" /> </layout> </appender> <root> <level value="info" /> <appender-ref ref="file" /> </root> </log4j:configuration>
but when export eclipse log4j.xml changed next one:
<?xml version="1.0" encoding="utf-8" ?> <!doctype log4j:configuration system "log4j.dtd"> <log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'> <appender name="file" class="org.apache.log4j.rollingfileappender"> <param name="file" value="/tmp/dlm/log4j.log" /> <param name="threshold" value="info" /> <param name="append" value="false" /> <param name="maxfilesize" value="1mb" /> <param name="maxbackupindex" value="1" /> <layout class="org.apache.log4j.patternlayout"> <param name="conversionpattern" value="%d %-5p %x{service} %x{user} [%c] %m%n" /> </layout> </appender> <appender name="console" class="org.apache.log4j.consoleappender"> <param name="target" value="system.out" /> <param name="threshold" value="error" /> <layout class="org.apache.log4j.patternlayout"> <param name="conversionpattern" value="%d{absolute} %-5p %x{service} %x{user} [%c{1}] %m%n" /> </layout> </appender> <root> <level value="info" /> <appender-ref ref="console" /> </root> </log4j:configuration>
i tried using log4j.properties file appear here, nothing.
thanks in advance answers.
thanks peter understood when run aplicacition eclipse using eclipse options , not maven build app. reason log4j.xml change. next solution not resolve why happens, resolve problem , give me correct way build app using 100% maven.
i need add new fields pom.xml make things eclipse options add automatically.
1.-include xml files:
<build> ... <!-- recursos --> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.fxml</include> <include>log4j.xml</include> </includes> </resource> </resources> ... </build>
2.- executable jar (i have 3 different main classes in same project):
<plugin> <artifactid>maven-assembly-plugin</artifactid> <configuration> <archive> <manifest> <mainclass>${class.main}</mainclass> </manifest> </archive> <descriptorrefs> <descriptorref>jar-with-dependencies</descriptorref> </descriptorrefs> </configuration> </plugin>
3.- add profiles select main class:
<profiles> <!-- dlm analog --> <profile> <id>dlmdesktopanalog</id> <properties> <class.main>cl.icpdas.dlm.desktop.fx.main.analog.dataloggeranalogmanager</class.main> </properties> </profile> <!-- dlm digital --> <profile> <id>dlmdesktopdigital</id> <properties> <class.main>cl.icpdas.dlm.desktop.fx.main.digital.dataloggerdigitalmanager</class.main> </properties> </profile> <!-- dlm extractor --> <profile> <id>dlmdesktopextractor</id> <properties> <class.main>cl.icpdas.dlm.desktop.fx.main.extractor.dataloggerextractormanager</class.main> </properties> </profile> </profiles>
finally, used next goals make executable jar.
mvn clean package assembly:single -e -p dlmdesktopanalog
anyway, if knows eclipse set log4j.xml , other options when make exejutable jar or reasson why changes log4j.xml answers wellcome comment.
Comments
Post a Comment