Martin Peřina has uploaded a new change for review.

Change subject: core: Replace log4j with JUL backend in bll tests
......................................................................

core: Replace log4j with JUL backend in bll tests

Replaces log4j with java.util.logging backend in bll tests.

Change-Id: I3ebeacfffd6de6766dc43c1d4fdf22d061781797
Bug-Url: https://bugzilla.redhat.com/1109871
Signed-off-by: Martin Perina <[email protected]>
---
M backend/manager/modules/bll/pom.xml
D backend/manager/modules/bll/src/test/resources/commons-logging.properties
D backend/manager/modules/bll/src/test/resources/log4j.xml
A backend/manager/modules/bll/src/test/resources/logging.properties
4 files changed, 46 insertions(+), 387 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/83/34183/1

diff --git a/backend/manager/modules/bll/pom.xml 
b/backend/manager/modules/bll/pom.xml
index 90dfc23..7e18716 100644
--- a/backend/manager/modules/bll/pom.xml
+++ b/backend/manager/modules/bll/pom.xml
@@ -137,10 +137,18 @@
         <artifactId>xmlrpc-client</artifactId>
     </dependency>
 
-    <!-- logging implementation used for unit tests -->
+    <!-- JUL is used as logging backend for tests -->
     <dependency>
       <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
+      <artifactId>slf4j-jdk14</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <!-- Needed until slf4j will be used as logging frontend in the whole 
project -->
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>jcl-over-slf4j</artifactId>
+      <version>${slf4j.version}</version>
       <scope>test</scope>
     </dependency>
 
@@ -166,26 +174,6 @@
   </dependencies>
 
   <build>
-
-   <testResources>
-      <testResource>
-        <directory>src/test/resources</directory>
-        <filtering>true</filtering>
-        <includes>
-          <include>log4j.xml</include>
-        </includes>
-      </testResource>
-      <testResource>
-        <directory>src/test/resources</directory>
-        <filtering>false</filtering>
-        <excludes>
-          <exclude>log4j.xml</exclude>
-        </excludes>
-      </testResource>
-
-    </testResources>
-
-
     <plugins>
       <plugin>
         <artifactId>maven-resources-plugin</artifactId>
@@ -212,16 +200,11 @@
       <plugin>
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
-          <systemProperties>
-            <property>
-             <name>jboss.server.log.dir</name>
-             <value>${project.build.directory}/logs/engine/</value>
-            </property>
-           <property>
-              <name>postgres.schema.name</name>
-              <value>${engine.schema}</value>
-            </property>
-        </systemProperties>
+          <systemPropertyVariables>
+            
<java.util.logging.config.file>src/test/resources/logging.properties</java.util.logging.config.file>
+            
<jboss.server.log.dir>${project.build.directory}/logs/engine/</jboss.server.log.dir>
+            <postgres.schema.name>${engine.schema}</postgres.schema.name>
+          </systemPropertyVariables>
 
          <!-- These environment variables are needed to run the tests
               using an alternative configuration that disables retries
diff --git 
a/backend/manager/modules/bll/src/test/resources/commons-logging.properties 
b/backend/manager/modules/bll/src/test/resources/commons-logging.properties
deleted file mode 100644
index fa93961..0000000
--- a/backend/manager/modules/bll/src/test/resources/commons-logging.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-# The Sun JSF RI bundles and wraps commons-logging, which, for unknown 
reasons, disables any other
-# commons-logging (my guess: the LogFactoryImpl detection routine is broken). 
This configuration
-# file makes it work again (also for unknown reasons).
-org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryImpl
-org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
\ No newline at end of file
diff --git a/backend/manager/modules/bll/src/test/resources/log4j.xml 
b/backend/manager/modules/bll/src/test/resources/log4j.xml
deleted file mode 100644
index 80f030b..0000000
--- a/backend/manager/modules/bll/src/test/resources/log4j.xml
+++ /dev/null
@@ -1,350 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE log4j:configuration SYSTEM 
"log4j.dtd">
-
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"; 
debug="false">
-
- <!-- Log levels:DEBUG,INFO,WARN,ERROR,FATAL -->
-   <appender name="FILE" class="org.apache.log4j.RollingFileAppender">
-     <errorHandler class="org.apache.log4j.helpers.OnlyOnceErrorHandler"/>
-     <param name="File" value="target/server.log"/>
-     <param name="Append" value="true"/>
-     <param name="MaxFileSize" value="10000KB"/>
-     <param name="MaxBackupIndex" value="5"/>
-
-     <layout class="org.apache.log4j.PatternLayout">
-       <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
-     </layout>
-   </appender>
-
-   <!-- ============================== -->
-   <!-- Append messages to the console -->
-   <!-- ============================== -->
-
-   <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
-      <errorHandler class="org.apache.log4j.helpers.OnlyOnceErrorHandler"/>
-      <param name="Target" value="System.out"/>
-      <param name="Threshold" value="INFO"/>
-
-      <layout class="org.apache.log4j.PatternLayout">
-         <!-- The default pattern: Date Priority [Category] Message\n -->
-         <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] 
%m%n"/>
-      </layout>
-   </appender>
-
-   <!-- ============================== -->
-   <!-- oVirt Appender                  -->
-   <!-- ============================== -->
-
-   <appender name="ENGINE_LOG" class="org.apache.log4j.RollingFileAppender">
-      <errorHandler class="org.apache.log4j.helpers.OnlyOnceErrorHandler"/>
-      <param name="File" value="target/engine.log"/>
-      <param name="Append" value="true"/>
-      <param name="MaxFileSize" value="10000KB"/>
-      <param name="MaxBackupIndex" value="9"/>
-      <param name="Threshold" value="DEBUG"/>
-      <layout class="org.apache.log4j.PatternLayout">
-         <param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n"/>
-      </layout>
-   </appender>
-
-<!-- ============================== -->
-   <!-- PublicAPI Appender                  -->
-   <!-- ============================== -->
-
-   <appender name="PUBLICAPI_LOG" class="org.apache.log4j.RollingFileAppender">
-      <errorHandler class="org.apache.log4j.helpers.OnlyOnceErrorHandler"/>
-      <param name="File" value="target/soap-api.log"/>
-      <param name="Append" value="true"/>
-      <param name="MaxFileSize" value="10000KB"/>
-      <param name="MaxBackupIndex" value="9"/>
-      <param name="Threshold" value="DEBUG"/>
-      <layout class="org.apache.log4j.PatternLayout">
-         <param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n"/>
-      </layout>
-   </appender>
-
-   <!-- ================ -->
-   <!-- Limit categories -->
-   <!-- ================ -->
-
-
-   <!-- Limit the org.apache category to INFO as its DEBUG is verbose -->
-   <category name="org.apache">
-      <priority value="INFO"/>
-   </category>
-
-   <!-- Limit the jacorb category to WARN as its INFO is verbose -->
-   <category name="jacorb">
-      <priority value="WARN"/>
-   </category>
-
-   <!-- Limit the org.jgroups category to WARN as its INFO is verbose -->
-   <category name="org.jgroups">
-      <priority value="WARN"/>
-   </category>
-
-   <!-- Limit the org.quartz category to INFO as its DEBUG is verbose -->
-   <category name="org.quartz">
-      <priority value="INFO"/>
-   </category>
-
-   <!-- Limit the com.sun category to INFO as its FINE is verbose -->
-   <category name="com.sun">
-      <priority value="INFO"/>
-   </category>
-
-   <!-- Limit the sun category to INFO as its FINE is verbose -->
-   <category name="sun">
-      <priority value="INFO"/>
-   </category>
-
-   <!-- Limit the javax.xml.bind category to INFO as its FINE is verbose -->
-   <category name="javax.xml.bind">
-      <priority value="INFO"/>
-   </category>
-
-   <!-- Limit JBoss categories
-   <category name="org.jboss">
-      <priority value="INFO"/>
-   </category>
-   -->
-
-   <!-- Limit the JSR77 categories -->
-   <category name="org.jboss.management">
-      <priority value="INFO"/>
-   </category>
-
-   <!-- Limit the verbose facelets compiler -->
-   <category name="facelets.compiler">
-      <priority value="WARN"/>
-   </category>
-
-   <!-- Limit the verbose ajax4jsf cache initialization -->
-   <category name="org.ajax4jsf.cache">
-      <priority value="WARN"/>
-   </category>
-
-   <!-- Limit the verbose embedded jopr categories -->
-   <category name="org.rhq">
-      <priority value="WARN"/>
-   </category>
-
-   <!-- Limit the verbose seam categories -->
-   <category name="org.jboss.seam">
-      <priority value="WARN"/>
-   </category>
-
-   <!-- Limit the verbose MC4J EMS (lib used by admin-console) categories -->
-   <category name="org.mc4j.ems">
-      <priority value="WARN"/>
-   </category>
-
-   <!-- Limit the org.springframework categories -->
-   <category name="org.springframework">
-      <priority value="WARN"/>
-   </category>
-
-
-   <!-- Show the evolution of the DataSource pool in the logs 
[inUse/Available/Max]
-   <category 
name="org.jboss.resource.connectionmanager.JBossManagedConnectionPool">
-     <priority value="TRACE"/>
-   </category>
-   -->
-
-   <!-- Category specifically for Security Audit Provider
-   <category name="org.jboss.security.audit.providers.LogAuditProvider" 
additivity="false">
-     <priority value="TRACE"/>
-     <appender-ref ref="AUDIT"/>
-   </category>
-   -->
-
-   <!-- Limit the org.jboss.serial (jboss-serialization) to INFO as its DEBUG 
is verbose -->
-   <category name="org.jboss.serial">
-      <priority value="INFO"/>
-   </category>
-
-   <!-- Decrease the priority threshold for the org.jboss.varia category
-   <category name="org.jboss.varia">
-     <priority value="DEBUG"/>
-   </category>
-   -->
-
-   <!-- Enable JBossWS message tracing
-   <category name="org.jboss.ws.core.MessageTrace">
-     <priority value="TRACE"/>
-   </category>
-   -->
-
-   <!--
-      | An example of enabling the custom TRACE level priority that is used
-      | by the JBoss internals to diagnose low level details. This example
-      | turns on TRACE level msgs for the org.jboss.ejb.plugins package and its
-      | subpackages. This will produce A LOT of logging output.
-      |
-      | Note: since jboss AS 4.2.x, the trace level is supported natively by
-      | log4j, so although the custom org.jboss.logging.XLevel priority will
-      | still work, there is no need to use it. The two examples that follow
-      | will both enable trace logging.
-   <category name="org.jboss.system">
-     <priority value="TRACE" class="org.jboss.logging.XLevel"/>
-   </category>
-   <category name="org.jboss.ejb.plugins">
-     <priority value="TRACE"/>
-   </category>
-   -->
-
-   <!--
-       | Logs these events to SNMP:
-           - server starts/stops
-           - cluster evolution (node death/startup)
-           - When an EJB archive is deployed (and associated verified messages)
-           - When an EAR archive is deployed
-
-   <category name="org.jboss.system.server.Server">
-     <priority value="INFO" />
-     <appender-ref ref="TRAP_LOG"/>
-   </category>
-
-   <category name="org.jboss.ha.framework.interfaces.HAPartition.lifecycle">
-     <priority value="INFO" />
-     <appender-ref ref="TRAP_LOG"/>
-   </category>
-
-   <category name="org.jboss.deployment.MainDeployer">
-     <priority value="ERROR" />
-     <appender-ref ref="TRAP_LOG"/>
-   </category>
-
-   <category name="org.jboss.ejb.EJBDeployer">
-     <priority value="INFO" />
-     <appender-ref ref="TRAP_LOG"/>
-
-   </category>
-
-   <category name="org.jboss.deployment.EARDeployer">
-     <priority value="INFO" />
-     <appender-ref ref="TRAP_LOG"/>
-   </category>
-   -->
-
-   <!-- Clustering logging -->
-   <!-- Uncomment the following to redirect the org.jgroups and
-      org.jboss.ha categories to a cluster.log file.
-
-   <appender name="CLUSTER" class="org.apache.log4j.RollingFileAppender">
-     <errorHandler class="org.apache.log4j.helpers.OnlyOnceErrorHandler"/>
-     <param name="File" value="${jboss.server.log.dir}/cluster.log"/>
-     <param name="Append" value="false"/>
-     <param name="MaxFileSize" value="500KB"/>
-     <param name="MaxBackupIndex" value="1"/>
-
-     <layout class="org.apache.log4j.PatternLayout">
-       <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
-     </layout>
-   </appender>
-   <category name="org.jgroups">
-     <priority value="DEBUG" />
-     <appender-ref ref="CLUSTER"/>
-   </category>
-   <category name="org.jboss.ha">
-     <priority value="DEBUG" />
-     <appender-ref ref="CLUSTER"/>
-   </category>
-   -->
-
-   <!-- ======================= -->
-   <!-- oVirt categories       -->
-   <!-- ======================= -->
-
-   <!--TOP configuration for all oVirt categories -->
-   <category name="org.ovirt.engine.core" additivity="false">
-       <priority value="INFO"/>
-       <appender-ref ref="ENGINE_LOG"/>
-   </category>
-
-   <!--Buisness Logic -->
-   <category name="org.ovirt.engine.core.bll">
-     <priority value="INFO"/>
-   </category>
-
-   <!--Vdsbroker -->
-   <category name="org.ovirt.engine.core.vdsbroker">
-     <priority value="INFO"/>
-   </category>
-
-   <!--utils -->
-   <category name="org.ovirt.engine.core.utils">
-     <priority value="INFO"/>
-   </category>
-
-   <!--Search backend -->
-   <category name="org.ovirt.engine.core.searchbackend">
-     <priority value="INFO"/>
-   </category>
-
-   <!--Common -->
-   <category name="org.ovirt.engine.core.common">
-     <priority value="INFO"/>
-   </category>
-
-   <!--Compact -->
-   <category name="org.ovirt.engine.core.compact">
-     <priority value="INFO"/>
-   </category>
-
-   <!--Encrypt utils-->
-   <category name="org.ovirt.engine.core.utils.crypt">
-     <priority value="INFO"/>
-   </category>
-
-   <!--REST API-->
-   <category name="org.ovirt.engine.core.restapi">
-     <priority value="INFO"/>
-   </category>
-
-   <!--Postgres causes lots of verboe messages in INFO level:
-        "Added default SqlReturnResultSet parameter named #result-set-1"-->
-   <category 
name="org.ovirt.engine.core.dal.dbbroker.PostgresDbEngineDialect$PostgresJdbcTemplate">
-        <priority value="WARN"/>
-   </category>
-
-   <!-- ======================= -->
-   <!-- Third party categories         -->
-   <!-- ======================= -->
-   
-   <category name="org.apache.xmlrpc" additivity="false">
-       <priority value="WARN"/>
-       <appender-ref ref="ENGINE_LOG"/>
-   </category>
-   
-   <category name="org.apache.sshd" additivity="false">
-       <priority value="WARN"/>
-       <appender-ref ref="ENGINE_LOG"/>
-   </category>
-
-   <category name="org.apache.commons.httpclient" additivity="false">
-        <priority value="WARN" />
-        <appender-ref ref="ENGINE_LOG" />
-   </category>
-
-   <category name="org.springframework.ldap" additivity="false">
-        <priority value="WARN" />
-        <appender-ref ref="ENGINE_LOG" />
-   </category>
-
-   <!-- ======================= -->
-   <!-- Setup the Root category -->
-   <!-- ======================= -->
-
-   <root>
-      <!--
-         Set the root logger priority via a system property. Note this is 
parsed by log4j,
-         so the full JBoss system property format is not supported; e.g.
-         setting a default via ${jboss.server.log.threshold:WARN} will not 
work.
-       -->
-      <priority value="${jboss.server.log.threshold}"/>
-      <appender-ref ref="CONSOLE"/>
-      <appender-ref ref="FILE"/>
-   </root>
-
-
-</log4j:configuration>
diff --git a/backend/manager/modules/bll/src/test/resources/logging.properties 
b/backend/manager/modules/bll/src/test/resources/logging.properties
new file mode 100644
index 0000000..ae75a59
--- /dev/null
+++ b/backend/manager/modules/bll/src/test/resources/logging.properties
@@ -0,0 +1,31 @@
+# Default format of log line is: DATE TIME LEVEL [SOURCE] Message Stacktrace
+java.util.logging.SimpleFormatter.format=%1$tY-%1$tm-%1$td 
%1$tH:%1$tM:%1$tS,%1$tL %4$-7s [%2$s] %5$s%6$s%n
+
+# Root handlers
+handlers=java.util.logging.FileHandler,java.util.logging.ConsoleHandler
+
+java.util.logging.FileHandler.append=true
+java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
+java.util.logging.FileHandler.pattern=target/engine.log
+
+java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
+java.util.logging.ConsoleHandler.level=INFO
+
+
+# Default logging level
+.level=INFO
+
+# Limit following categories not to be too verbose
+org.ovirt.engine.core.dal.dbbroker.PostgresDbEngineDialect$PostgresJdbcTemplate.level=WARNING
+
+facelets.compiler.level=WARNING
+jacorb.level=WARNING
+org.ajax4jsf.cache.level=WARNING
+org.apache.commons.httpclient.level=WARNING
+org.apache.sshd.level=WARNING
+org.apache.xmlrpc.level=WARNING
+org.jboss.seam.level=WARNING
+org.jgroups.level=WARNING
+org.mc4j.ems.level=WARNING
+org.rhq.level=WARNING
+org.springframework.level=WARNING


-- 
To view, visit http://gerrit.ovirt.org/34183
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3ebeacfffd6de6766dc43c1d4fdf22d061781797
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Martin Peřina <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to