logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nickwilli...@apache.org
Subject svn commit: r1505255 - in /logging/log4j/log4j2/trunk/core/src/test: java/org/apache/logging/log4j/core/appender/db/jpa/JPAAppenderTest.java resources/META-INF/persistence.xml resources/org/apache/logging/log4j/core/appender/db/jpa/log4j2-jpa-basic.xml
Date Sun, 21 Jul 2013 03:10:03 GMT
Author: nickwilliams
Date: Sun Jul 21 03:10:01 2013
New Revision: 1505255

URL: http://svn.apache.org/r1505255
Log:
Creating performance test for JPA Appender

Modified:
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/JPAAppenderTest.java
    logging/log4j/log4j2/trunk/core/src/test/resources/META-INF/persistence.xml
    logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jpa/log4j2-jpa-basic.xml

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/JPAAppenderTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/JPAAppenderTest.java?rev=1505255&r1=1505254&r2=1505255&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/JPAAppenderTest.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/JPAAppenderTest.java
Sun Jul 21 03:10:01 2013
@@ -270,6 +270,46 @@ public class JPAAppenderTest {
         }
     }
 
+    @Test
+    public void testPerformanceOfAppenderWith10000EventsUsingBasicEntity() throws SQLException
{
+        try {
+            this.setUp("log4j2-jpa-basic.xml");
+
+            final Error exception = new Error("Goodbye, cruel world!");
+
+            final Logger logger = LogManager.getLogger(this.getClass().getName() +
+                    ".testPerformanceOfAppenderWith10000EventsUsingBasicEntity");
+            logger.info("This is a warm-up message.");
+
+            System.out.println("Starting a performance test for JDBC Appender for hsqldb.");
+
+            long start = System.nanoTime();
+
+            for(int i = 0; i < 10000; i++) {
+                if (i % 25 == 0) {
+                    logger.warn("This is an exception message.", exception);
+                } else {
+                    logger.info("This is an info message.");
+                }
+            }
+
+            long elapsed = System.nanoTime() - start;
+            long elapsedMilli = elapsed / 1000000;
+
+            final Statement statement = this.connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
+                    ResultSet.CONCUR_READ_ONLY);
+            final ResultSet resultSet = statement.executeQuery("SELECT * FROM jpaBasicLogEntry
ORDER BY id");
+
+            resultSet.last();
+            assertEquals("The number of records is not correct.", 10001, resultSet.getRow());
+
+            System.out.println("Wrote 10,000 log events in " + elapsed + " nanoseconds ("
+ elapsedMilli +
+                    " milliseconds) for hsqldb.");
+        } finally {
+            this.tearDown();
+        }
+    }
+
     @SuppressWarnings("unused")
     public static class BadConstructorEntity1 extends TestBaseEntity {
         private static final long serialVersionUID = 1L;

Modified: logging/log4j/log4j2/trunk/core/src/test/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/resources/META-INF/persistence.xml?rev=1505255&r1=1505254&r2=1505255&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/resources/META-INF/persistence.xml (original)
+++ logging/log4j/log4j2/trunk/core/src/test/resources/META-INF/persistence.xml Sun Jul 21
03:10:01 2013
@@ -33,9 +33,9 @@
       <property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:mem:Log4j;ifexists=true"/>
       <property name="javax.persistence.jdbc.user" value="sa"/>
       <property name="javax.persistence.jdbc.password" value=""/>
-      <property name="eclipselink.logging.level" value="FINE"/>
+      <!--<property name="eclipselink.logging.level" value="FINE"/>
       <property name="eclipselink.logging.level.sql" value="FINE"/>
-      <property name="eclipselink.logging.parameters" value="true"/>
+      <property name="eclipselink.logging.parameters" value="true"/> uncomment to troubleshoot
SQL-->
     </properties>
   </persistence-unit>
 

Modified: logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jpa/log4j2-jpa-basic.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jpa/log4j2-jpa-basic.xml?rev=1505255&r1=1505254&r2=1505255&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jpa/log4j2-jpa-basic.xml
(original)
+++ logging/log4j/log4j2/trunk/core/src/test/resources/org/apache/logging/log4j/core/appender/db/jpa/log4j2-jpa-basic.xml
Sun Jul 21 03:10:01 2013
@@ -26,7 +26,7 @@
   </appenders>
 
   <loggers>
-    <logger name="org.apache.logging.log4j.core.appender.db" level="debug">
+    <logger name="org.apache.logging.log4j.core.appender.db" level="debug" additivity="false">
       <appender-ref ref="databaseAppender" />
     </logger>
 



Mime
View raw message