The issue was not due to log4j version. It was because one of the dependency (s3ninja <https://github.com/scireum/s3ninja>) we were using during testing. It seems it was also using log4j and has its default log level set to INFO. To solve this I also set s3ninja's log level to the rootLogger level that is set in src/test/resources/log4j.properties. Something like below:-
Setup setup = new Setup(Mode.TEST, ClassLoader.getSystemClassLoader()); setup.withDefaultLogLevel(Logger.getRootLogger().getLevel());Sirius.start(setup); On Wed, Jun 15, 2016 at 11:42 PM, Debraj Manna <[email protected]> wrote: > Yes we have a seperate config for testing and anothet used by karaf. > On Jun 15, 2016 11:40 PM, "Matt Sicker" <[email protected]> wrote: > >> I thought karaf used a file called org.ops4j.pax.logging.cfg, not >> log4j.properties. If you do that, then you'll have one config used for >> testing and another used by karaf. >> >> On 15 June 2016 at 12:50, Debraj Manna <[email protected]> wrote: >> >> > Is it possible to resolve my issue without upgrading to log4j2? >> > >> > I am asking this because right now we are using log4j in a karaf >> bundle. If >> > we are moving to log4j2 we also have to configure karaf to use as >> log4j2. >> > On Jun 15, 2016 9:50 PM, "Matt Sicker" <[email protected]> wrote: >> > >> > > That's not the right artifact. Take a look here: < >> > > http://logging.apache.org/log4j/2.x/manual/migration.html> >> > > >> > > On 15 June 2016 at 11:16, Debraj Manna <[email protected]> >> wrote: >> > > >> > > > I updated my pom as shown below. Rest all are same. But still no >> luck. >> > > Same >> > > > issue all INFO logs are getting printed even though I have specified >> > > ERROR >> > > > log level in my src/test/resources/log4j.properties >> > > > >> > > > Added the below dependency:- >> > > > >> > > > <dependency> >> > > > >> > > > <groupId>org.apache.logging.log4j</groupId> >> > > > >> > > > <artifactId>log4j</artifactId> >> > > > >> > > > <version>2.6</version> >> > > > >> > > > <type>pom</type> >> > > > >> > > > </dependency> >> > > > >> > > > >> > > > Removed the below dependency:- >> > > > >> > > > <dependency> >> > > > >> > > > <groupId>log4j</groupId> >> > > > >> > > > <artifactId>log4j</artifactId> >> > > > >> > > > <version>1.2.17</version> >> > > > >> > > > </dependency> >> > > > >> > > > On Wed, Jun 15, 2016 at 9:17 PM, Ralph Goers < >> > [email protected] >> > > > >> > > > wrote: >> > > > >> > > > > You are using log4j 1.2.17, which reached end-of-life last year. >> We >> > > > > recommend you upgrade to Log4j 2 since we no longer support log4j >> 1. >> > > > > >> > > > > Ralph >> > > > > >> > > > > > On Jun 15, 2016, at 6:04 AM, Debraj Manna < >> > [email protected]> >> > > > > wrote: >> > > > > > >> > > > > > I want to log only the ERROR during testing in maven. For this >> > > purpose >> > > > I >> > > > > > created a file src/test/resources/log4j.properties, which is >> going >> > to >> > > > > > override the configuration I already have in >> > > > > > src/main/resources/log4j.properties. But this is not working. My >> > > > > > log4j.properties looks like below:- >> > > > > > >> > > > > > log4j.rootLogger=ERROR, out, stdout >> > > > > > # CONSOLE appender >> > > > > > log4j.appender.stdout=org.apache.log4j.ConsoleAppender >> > > > > > log4j.appender.stdout.layout=org.apache.log4j.PatternLayout >> > > > > > >> > > > > >> > > > >> > > >> > >> log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ} >> > > > > > | %-5.5p | %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{ >> bundle.name >> > } >> > > - >> > > > > > %X{bundle.version} | %X | %m%n#log4j.logger.org.apache.http=INFO >> > > > > > # File appender >> > > > > > log4j.appender.out=org.apache.log4j.DailyRollingFileAppender >> > > > > > log4j.appender.out.File=/tmp/wf_test.log >> > > > > > log4j.appender.out.DatePattern='.'yyyy-MM-dd >> > > > > > log4j.appender.out.Append=true >> > > > > > log4j.appender.out.layout=org.apache.log4j.PatternLayout >> > > > > > >> > > > > >> > > > >> > > >> > >> log4j.appender.out.layout.ConversionPattern=%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ} >> > > > > > | %-5.5p | %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{ >> bundle.name >> > } >> > > - >> > > > > > %X{bundle.version} | %X | %m%n >> > > > > > >> > > > > > My pom.xml looks like below:- >> > > > > > >> > > > > > <project xmlns="http://maven.apache.org/POM/4.0.0" >> > > > > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >> > > > > > xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 >> > > > > > http://maven.apache.org/xsd/maven-4.0.0.xsd"> >> > > > > > <modelVersion>4.0.0</modelVersion> >> > > > > > >> > > > > > <groupId>com.jabong.orchestratorservice</groupId> >> > > > > > <artifactId>basecomponent</artifactId> >> > > > > > <version>0.0.1</version> >> > > > > > <packaging>bundle</packaging> >> > > > > > <name>basecomponent</name> >> > > > > > <url>http://maven.apache.org</url> >> > > > > > >> > > > > > <properties> >> > > > > > >> > > > <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> >> > > > > > <camel.version>2.16.1</camel.version> >> > > > > > <jackson.version>2.7.4</jackson.version> >> > > > > > >> > > <jackson.afterburner.version>2.7.1</jackson.afterburner.version> >> > > > > > <runSuite>**/AllTestSuite.class</runSuite> >> > > > > > <sonar.host.url>http://sonar:9000/</sonar.host.url> >> > > > > > <sonar.jdbc.username>sonar</sonar.jdbc.username> >> > > > > > <sonar.jdbc.password>sonar</sonar.jdbc.password> >> > > > > > >> > > > > >> > > > >> > > >> > >> <sonar.jdbc.url>jdbc:mysql://sonar:3306/sonar?useUnicode=true&characterEncoding=utf8</sonar.jdbc.url> >> > > > > > >> > > > > >> > > > >> > > >> > >> <sonar.jdbc.driverClassName>com.mysql.jdbc.Driver</sonar.jdbc.driverClassName> >> > > > > > <sonar.binaries>target</sonar.binaries> >> > > > > > <sonar.tests>src/test</sonar.tests> >> > > > > > >> <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis> >> > > > > > >> > > > > >> <sonar.junit.reportsPath>build/test-reports</sonar.junit.reportsPath> >> > > > > > >> > <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin> >> > > > > > >> > > > > >> <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin> >> > > > > > >> <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis> >> > > > > > >> > > > > >> > > > >> > > >> > >> <sonar.jacoco.reportPath>${project.basedir}/../target/jacoco.exec</sonar.jacoco.reportPath> >> > > > > > </properties> >> > > > > > >> > > > > > <dependencies> >> > > > > > <dependency> >> > > > > > <groupId>commons-fileupload</groupId> >> > > > > > <artifactId>commons-fileupload</artifactId> >> > > > > > <version>1.3.1</version> >> > > > > > </dependency> >> > > > > > <dependency> >> > > > > > <groupId>commons-httpclient</groupId> >> > > > > > <artifactId>commons-httpclient</artifactId> >> > > > > > <version>3.1</version> >> > > > > > <scope>test</scope> >> > > > > > </dependency> >> > > > > > <dependency> >> > > > > > <groupId>org.hsqldb</groupId> >> > > > > > <artifactId>hsqldb</artifactId> >> > > > > > <version>2.3.3</version> >> > > > > > <scope>test</scope> >> > > > > > </dependency> >> > > > > > <dependency> >> > > > > > <groupId>junit</groupId> >> > > > > > <artifactId>junit</artifactId> >> > > > > > <version>4.12</version> >> > > > > > <scope>test</scope> >> > > > > > </dependency> >> > > > > > <dependency> >> > > > > > <groupId>com.fasterxml.jackson.core</groupId> >> > > > > > <artifactId>jackson-core</artifactId> >> > > > > > <version>${jackson.version}</version> >> > > > > > </dependency> >> > > > > > <dependency> >> > > > > > <groupId>com.fasterxml.jackson.core</groupId> >> > > > > > <artifactId>jackson-annotations</artifactId> >> > > > > > <version>${jackson.version}</version> >> > > > > > </dependency> >> > > > > > >> > > > > > <dependency> >> > > > > > <groupId>com.fasterxml.jackson.core</groupId> >> > > > > > <artifactId>jackson-databind</artifactId> >> > > > > > <version>${jackson.version}</version> >> > > > > > </dependency> >> > > > > > >> > > > > > <dependency> >> > > > > > <groupId>com.fasterxml.jackson.module</groupId> >> > > > > > <artifactId>jackson-module-afterburner</artifactId> >> > > > > > <version>${jackson.afterburner.version}</version> >> > > > > > </dependency> >> > > > > > >> > > > > > <dependency> >> > > > > > <groupId>com.github.arnabk</groupId> >> > > > > > <artifactId>java-dogstatsd-client</artifactId> >> > > > > > <version>1.0.1</version> >> > > > > > </dependency> >> > > > > > <dependency> >> > > > > > <groupId>org.json</groupId> >> > > > > > <artifactId>json</artifactId> >> > > > > > <version>20151123</version> >> > > > > > </dependency> >> > > > > > <dependency> >> > > > > > <groupId>javax.xml.bind</groupId> >> > > > > > <artifactId>jaxb-api</artifactId> >> > > > > > <version>2.2.11</version> >> > > > > > </dependency> >> > > > > > <dependency> >> > > > > > <groupId>org.im4java</groupId> >> > > > > > <artifactId>im4java</artifactId> >> > > > > > <version>1.4.0</version> >> > > > > > </dependency> >> > > > > > <dependency> >> > > > > > <groupId> >> > > > > > com.googlecode.maven-java-formatter-plugin >> > > > > > </groupId> >> > > > > > <artifactId>maven-java-formatter-plugin</artifactId> >> > > > > > <version>0.4</version> >> > > > > > </dependency> >> > > > > > <dependency> >> > > > > > <groupId>mysql</groupId> >> > > > > > <artifactId>mysql-connector-java</artifactId> >> > > > > > <version>5.1.6</version> >> > > > > > </dependency> >> > > > > > <dependency> >> > > > > > <groupId>commons-dbcp</groupId> >> > > > > > <artifactId>commons-dbcp</artifactId> >> > > > > > <version>1.4</version> >> > > > > > </dependency> >> > > > > > <dependency> >> > > > > > <groupId>org.slf4j</groupId> >> > > > > > <artifactId>slf4j-api</artifactId> >> > > > > > <version>1.7.12</version> >> > > > > > </dependency> >> > > > > > <dependency> >> > > > > > <groupId>org.slf4j</groupId> >> > > > > > <artifactId>slf4j-log4j12</artifactId> >> > > > > > <version>1.7.12</version> >> > > > > > </dependency> >> > > > > > <dependency> >> > > > > > <groupId>log4j</groupId> >> > > > > > <artifactId>log4j</artifactId> >> > > > > > <version>1.2.17</version> >> > > > > > </dependency> >> > > > > > <dependency> >> > > > > > <groupId>net.java.dev.jna</groupId> >> > > > > > <artifactId>jna</artifactId> >> > > > > > <version>4.2.2</version> >> > > > > > </dependency> >> > > > > > <dependency> >> > > > > > <groupId>org.apache.camel</groupId> >> > > > > > <artifactId>camel-jdbc</artifactId> >> > > > > > <version>${camel.version}</version> >> > > > > > <scope>provided</scope> >> > > > > > </dependency> >> > > > > > <dependency> >> > > > > > <groupId>org.apache.camel</groupId> >> > > > > > <artifactId>camel-jetty</artifactId> >> > > > > > <version>${camel.version}</version> >> > > > > > <scope>provided</scope> >> > > > > > </dependency> >> > > > > > <dependency> >> > > > > > <groupId>org.apache.camel</groupId> >> > > > > > <artifactId>camel-http4</artifactId> >> > > > > > <version>${camel.version}</version> >> > > > > > <scope>provided</scope> >> > > > > > </dependency> >> > > > > > <dependency> >> > > > > > <groupId>org.apache.camel</groupId> >> > > > > > <artifactId>camel-aws</artifactId> >> > > > > > <version>${camel.version}</version> >> > > > > > <scope>provided</scope> >> > > > > > </dependency> >> > > > > > <dependency> >> > > > > > <groupId>org.apache.camel</groupId> >> > > > > > <artifactId>camel-core</artifactId> >> > > > > > <version>${camel.version}</version> >> > > > > > <scope>provided</scope> >> > > > > > </dependency> >> > > > > > <dependency> >> > > > > > <groupId>org.apache.camel</groupId> >> > > > > > <artifactId>camel-test</artifactId> >> > > > > > <version>${camel.version}</version> >> > > > > > <scope>test</scope> >> > > > > > </dependency> >> > > > > > <dependency> >> > > > > > <groupId>com.github.tomakehurst</groupId> >> > > > > > <artifactId>wiremock</artifactId> >> > > > > > <version>1.58</version> >> > > > > > <scope>test</scope> >> > > > > > </dependency> >> > > > > > <dependency> >> > > > > > <groupId>net.javacrumbs.json-unit</groupId> >> > > > > > <artifactId>json-unit</artifactId> >> > > > > > <version>1.11.0</version> >> > > > > > <scope>test</scope> >> > > > > > </dependency> >> > > > > > <dependency> >> > > > > > <groupId>com.scireum</groupId> >> > > > > > <artifactId>s3ninja</artifactId> >> > > > > > <version>2.7</version> >> > > > > > <scope>test</scope> >> > > > > > </dependency> >> > > > > > </dependencies> >> > > > > > >> > > > > > <profiles> >> > > > > > <profile> >> > > > > > <activation> >> > > > > > <property> >> > > > > > <name>!maven.test.skip</name> >> > > > > > </property> >> > > > > > </activation> >> > > > > > >> > > > > > <build> >> > > > > > <resources> >> > > > > > <resource> >> > > > > > <directory>src/main/resources</directory> >> > > > > > <excludes> >> > > > > > <exclude>**/*.cfg</exclude> >> > > > > > </excludes> >> > > > > > </resource> >> > > > > > </resources> >> > > > > > <testResources> >> > > > > > <testResource> >> > > > > > >> > > > > > <directory>${project.basedir}/src/test/resources/</directory> >> > > > > > </testResource> >> > > > > > <testResource> >> > > > > > >> > > > > > >> > <directory>${project.basedir}/src/test/resources/config/</directory> >> > > > > > </testResource> >> > > > > > </testResources> >> > > > > > <pluginManagement> >> > > > > > <plugins> >> > > > > > <plugin> >> > > > > > >> > > > <artifactId>maven-compiler-plugin</artifactId> >> > > > > > <version>3.3</version> >> > > > > > <configuration> >> > > > > > <source>1.8</source> >> > > > > > <target>1.8</target> >> > > > > > </configuration> >> > > > > > </plugin> >> > > > > > </plugins> >> > > > > > </pluginManagement> >> > > > > > <plugins> >> > > > > > <plugin> >> > > > > > >> <groupId>org.apache.maven.plugins</groupId> >> > > > > > >> > <artifactId>maven-surefire-plugin</artifactId> >> > > > > > <version>2.19.1</version> >> > > > > > <configuration> >> > > > > > <includes> >> > > > > > <include>${runSuite}</include> >> > > > > > </includes> >> > > > > > <!-- <skipTests>true</skipTests> --> >> > > > > > </configuration> >> > > > > > </plugin> >> > > > > > <plugin> >> > > > > > <groupId>org.jacoco</groupId> >> > > > > > >> <artifactId>jacoco-maven-plugin</artifactId> >> > > > > > <version>0.7.0.201403182114</version> >> > > > > > <executions> >> > > > > > <execution> >> > > > > > <goals> >> > > > > > <goal>prepare-agent</goal> >> > > > > > </goals> >> > > > > > </execution> >> > > > > > </executions> >> > > > > > <configuration> >> > > > > > >> > > > > <destFile>${sonar.jacoco.reportPath}</destFile> >> > > > > > </configuration> >> > > > > > </plugin> >> > > > > > <!-- Documentation at >> > > > > > >> > > > > >> > > > >> > > >> > >> https://karaf.apache.org/manual/latest/developers-guide/karaf-maven-plugin.html >> > > > > > --> >> > > > > > <plugin> >> > > > > > <groupId>org.apache.felix</groupId> >> > > > > > >> <artifactId>maven-bundle-plugin</artifactId> >> > > > > > <version>3.0.1</version> >> > > > > > <extensions>true</extensions> >> > > > > > <configuration> >> > > > > > <instructions> >> > > > > > >> > > > > > <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> >> > > > > > >> > > > > > <Bundle-Description>${project.description}</Bundle-Description> >> > > > > > >> > > > > > <Import-Package>*;resolution:=optional</Import-Package> >> > > > > > </instructions> >> > > > > > </configuration> >> > > > > > </plugin> >> > > > > > </plugins> >> > > > > > </build> >> > > > > > </profile> >> > > > > > </profiles> </project> >> > > > > > >> > > > > > But setting log level to ERROR or some other value in >> > > log4j.properties >> > > > is >> > > > > > not making any effect. The actual level is always INFO. I have >> gone >> > > > > through >> > > > > > this question >> > > > > > < >> > > > > >> > > > >> > > >> > >> http://stackoverflow.com/questions/4106524/how-to-override-log4j-properties-during-testing >> > > > > > >> > > > > > and >> > > > > > tried modifying my sure-fire plugin configuration but still no >> > luck. >> > > > > > >> > > > > > <plugin> >> > > > > > <groupId>org.apache.maven.plugins</groupId> >> > > > > > <artifactId>maven-surefire-plugin</artifactId> >> > > > > > <version>2.19.1</version> >> > > > > > <configuration> >> > > > > > <includes> >> > > > > > <include>${runSuite}</include> >> > > > > > </includes> >> > > > > > <systemPropertyVariables> >> > > > > > >> > > > > >> > > > >> > > >> > >> <log4j.configuration>file:src/test/resources/log4j-surefire.properties</log4j.configuration> >> > > > > > </systemPropertyVariables> >> > > > > > </configuration></plugin> >> > > > > > >> > > > > > Maven version is as below:- >> > > > > > >> > > > > > jabongs-MacBook-Pro-4:basecomponent debraj$ mvn -vApache Maven >> > 3.3.9 >> > > > > > (bb52d8502b132ec0a5a3f4c09453c07478323dc5; >> > > > > > 2015-11-10T22:11:47+05:30)Maven home: >> > > > > > /Users/debraj/Downloads/apache-maven-3.3.9Java version: >> 1.8.0_77, >> > > > > > vendor: Oracle CorporationJava home: >> > > > > > >> > > > > >> > > > >> > > >> > >> /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jreDefault >> > > > > > locale: en_US, platform encoding: UTF-8 >> > > > > > OS name: "mac os x", version: "10.11.4", arch: "x86_64", family: >> > > "mac" >> > > > > > >> > > > > > The issue is there only in test config and during the test >> > execution. >> > > > If >> > > > > > the log level is changed in src/main/resources/log4j.properties >> > then >> > > > > during >> > > > > > the main application run the log level messages are fine. >> > > > > > >> > > > > > Can someone let me know what is going wrong? >> > > > > >> > > > > >> > > > > >> > > > > >> --------------------------------------------------------------------- >> > > > > To unsubscribe, e-mail: [email protected] >> > > > > For additional commands, e-mail: >> [email protected] >> > > > > >> > > > > >> > > > >> > > >> > > >> > > >> > > -- >> > > Matt Sicker <[email protected]> >> > > >> > >> >> >> >> -- >> Matt Sicker <[email protected]> >> >
