diff --git a/backends/jgroups/pom.xml b/backends/jgroups/pom.xml index c2c15a243e3..885afaea795 100644 --- a/backends/jgroups/pom.xml +++ b/backends/jgroups/pom.xml @@ -72,8 +72,8 @@ test - log4j - log4j + org.apache.logging.log4j + log4j-core test diff --git a/backends/jgroups/src/test/resources/log4j.properties b/backends/jgroups/src/test/resources/log4j.properties deleted file mode 100644 index 4c125c88749..00000000000 --- a/backends/jgroups/src/test/resources/log4j.properties +++ /dev/null @@ -1,48 +0,0 @@ -### direct log messages to stdout ### -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n - -### direct messages to file hibernate.log ### -log4j.appender.file=org.apache.log4j.FileAppender -log4j.appender.file.File=hibernate.log -log4j.appender.file.layout=org.apache.log4j.PatternLayout -log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n - -### set log levels - for more verbose logging change 'info' to 'debug' ### - -log4j.rootLogger=debug, stdout -log4j.logger.org.jboss=info -#log4j.logger.com.jboss=debug - -log4j.logger.org.hibernate=warn - -log4j.logger.org.hibernate.search=debug -log4j.logger.org.apache.http=info - -### log just the SQL -#log4j.logger.org.hibernate.SQL=debug - -#log4j.logger.org.hibernate.engine.CascadingAction=debug - -### log JDBC bind parameters ### -#log4j.logger.org.hibernate.type=debug - -### log schema export/update ### -log4j.logger.org.hibernate.tool.hbm2ddl=warn - -### log cache activity ### -#log4j.logger.org.hibernate.cache=debug - -### enable the following line if you want to track down connection ### -### leakages when using DriverManagerConnectionProvider ### -#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace - -### annotation logs -#log4j.logger.org.hibernate.annotation=info -#log4j.logger.org.hibernate.cfg=info -#log4j.logger.org.hibernate.cfg.SettingsFactory=info -#log4j.logger.org.hibernate.cfg.AnnotationBinder=info -#log4j.logger.org.hibernate.cfg.AnnotationConfiguration=info -#log4j.logger.org.hibernate.cfg.Ejb3Column=info diff --git a/backends/jgroups/src/test/resources/log4j2.properties b/backends/jgroups/src/test/resources/log4j2.properties new file mode 100644 index 00000000000..270d3ed7aba --- /dev/null +++ b/backends/jgroups/src/test/resources/log4j2.properties @@ -0,0 +1,29 @@ +### direct log messages to stdout ### +appender.stdout.type=Console +appender.stdout.name=STDOUT +appender.stdout.layout.type=PatternLayout +appender.stdout.layout.pattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n + +## Loggers +rootLogger.level=info +rootLogger.appenderRef.stdout.ref=STDOUT + +### JBoss logger +logger.jboss.name=org.jboss +logger.jboss.level=info + +### Hibernate logger +logger.hibernate.name=org.hibernate +logger.hibernate.level=info + +### Search logger +logger.search.name=org.hibernate.search +logger.search.level=info + +### Hbm2ddl logger +logger.hbm2ddl.name=org.hibernate.tool.hbm2ddl +logger.hbm2ddl.level=warn + +### Elasticsearch logger +logger.elasticsearch.name=org.elasticsearch.client +logger.elasticsearch.level=debug diff --git a/elasticsearch/pom.xml b/elasticsearch/pom.xml index aa81692392d..8bb855b832d 100644 --- a/elasticsearch/pom.xml +++ b/elasticsearch/pom.xml @@ -101,8 +101,8 @@ test - log4j - log4j + org.apache.logging.log4j + log4j-core test diff --git a/elasticsearch/src/test/resources/log4j.properties b/elasticsearch/src/test/resources/log4j.properties deleted file mode 100644 index ca84f5684da..00000000000 --- a/elasticsearch/src/test/resources/log4j.properties +++ /dev/null @@ -1,57 +0,0 @@ -### direct log messages to stdout ### -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n - -### direct messages to file hibernate.log ### -log4j.appender.file=org.apache.log4j.FileAppender -log4j.appender.file.File=hibernate.log -log4j.appender.file.layout=org.apache.log4j.PatternLayout -log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n - -### direct messages to socket - chainsaw ### -log4j.appender.socket=org.apache.log4j.net.SocketAppender -log4j.appender.socket.remoteHost=localhost -log4j.appender.socket.port=4560 -log4j.appender.socket.locationInfo=true - -### set log levels - for more verbose logging change 'info' to 'debug' ### - -log4j.rootLogger=info, stdout -log4j.logger.org.jboss=info -#log4j.logger.com.jboss=debug - -log4j.logger.org.hibernate=warn - -log4j.logger.org.hibernate.search=debug -log4j.logger.org.apache.http=info -log4j.logger.org.elasticsearch.client=debug -log4j.logger.org.hibernate.search.elasticsearch.request=debug -#log4j.logger.org.hibernate.search.backend=debug - -### log just the SQL -#log4j.logger.org.hibernate.SQL=debug - -#log4j.logger.org.hibernate.engine.CascadingAction=debug - -### log JDBC bind parameters ### -#log4j.logger.org.hibernate.type=debug - -### log schema export/update ### -log4j.logger.org.hibernate.tool.hbm2ddl=warn - -### log cache activity ### -#log4j.logger.org.hibernate.cache=debug - -### enable the following line if you want to track down connection ### -### leakages when using DriverManagerConnectionProvider ### -#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace - -### annotation logs -#log4j.logger.org.hibernate.annotation=info -#log4j.logger.org.hibernate.cfg=info -#log4j.logger.org.hibernate.cfg.SettingsFactory=info -#log4j.logger.org.hibernate.cfg.AnnotationBinder=info -#log4j.logger.org.hibernate.cfg.AnnotationConfiguration=info -#log4j.logger.org.hibernate.cfg.Ejb3Column=info diff --git a/elasticsearch/src/test/resources/log4j2.properties b/elasticsearch/src/test/resources/log4j2.properties new file mode 100644 index 00000000000..270d3ed7aba --- /dev/null +++ b/elasticsearch/src/test/resources/log4j2.properties @@ -0,0 +1,29 @@ +### direct log messages to stdout ### +appender.stdout.type=Console +appender.stdout.name=STDOUT +appender.stdout.layout.type=PatternLayout +appender.stdout.layout.pattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n + +## Loggers +rootLogger.level=info +rootLogger.appenderRef.stdout.ref=STDOUT + +### JBoss logger +logger.jboss.name=org.jboss +logger.jboss.level=info + +### Hibernate logger +logger.hibernate.name=org.hibernate +logger.hibernate.level=info + +### Search logger +logger.search.name=org.hibernate.search +logger.search.level=info + +### Hbm2ddl logger +logger.hbm2ddl.name=org.hibernate.tool.hbm2ddl +logger.hbm2ddl.level=warn + +### Elasticsearch logger +logger.elasticsearch.name=org.elasticsearch.client +logger.elasticsearch.level=debug diff --git a/engine/pom.xml b/engine/pom.xml index a976b45c7ed..5d96575151a 100644 --- a/engine/pom.xml +++ b/engine/pom.xml @@ -99,8 +99,8 @@ test - log4j - log4j + org.apache.logging.log4j + log4j-core test diff --git a/engine/src/test/java/org/hibernate/search/test/analyzer/common/PropertyLevelAnalyzerDeprecationTest.java b/engine/src/test/java/org/hibernate/search/test/analyzer/common/PropertyLevelAnalyzerDeprecationTest.java index 3069d595716..c23926a4ee3 100644 --- a/engine/src/test/java/org/hibernate/search/test/analyzer/common/PropertyLevelAnalyzerDeprecationTest.java +++ b/engine/src/test/java/org/hibernate/search/test/analyzer/common/PropertyLevelAnalyzerDeprecationTest.java @@ -18,7 +18,7 @@ import org.junit.Rule; import org.junit.Test; -import org.apache.log4j.Level; +import org.apache.logging.log4j.Level; import org.apache.lucene.analysis.core.WhitespaceAnalyzer; import org.hamcrest.CoreMatchers; diff --git a/engine/src/test/java/org/hibernate/search/test/analyzer/common/TypeLevelAnalyzerDeprecationTest.java b/engine/src/test/java/org/hibernate/search/test/analyzer/common/TypeLevelAnalyzerDeprecationTest.java index feccf5ab5e5..94842c48245 100644 --- a/engine/src/test/java/org/hibernate/search/test/analyzer/common/TypeLevelAnalyzerDeprecationTest.java +++ b/engine/src/test/java/org/hibernate/search/test/analyzer/common/TypeLevelAnalyzerDeprecationTest.java @@ -18,7 +18,7 @@ import org.junit.Rule; import org.junit.Test; -import org.apache.log4j.Level; +import org.apache.logging.log4j.Level; import org.apache.lucene.analysis.core.WhitespaceAnalyzer; import org.hamcrest.CoreMatchers; diff --git a/engine/src/test/java/org/hibernate/search/test/configuration/IndexNameOverrideDeprecationTest.java b/engine/src/test/java/org/hibernate/search/test/configuration/IndexNameOverrideDeprecationTest.java index ee8715d1ba2..199ea1bfa98 100644 --- a/engine/src/test/java/org/hibernate/search/test/configuration/IndexNameOverrideDeprecationTest.java +++ b/engine/src/test/java/org/hibernate/search/test/configuration/IndexNameOverrideDeprecationTest.java @@ -17,7 +17,7 @@ import org.junit.Rule; import org.junit.Test; -import org.apache.log4j.Level; +import org.apache.logging.log4j.Level; import org.hamcrest.CoreMatchers; @TestForIssue(jiraKey = "HSEARCH-4336") diff --git a/engine/src/test/java/org/hibernate/search/test/configuration/IndexWriterTuningAppliedTest.java b/engine/src/test/java/org/hibernate/search/test/configuration/IndexWriterTuningAppliedTest.java index 4bfdf202779..1423cc123e4 100644 --- a/engine/src/test/java/org/hibernate/search/test/configuration/IndexWriterTuningAppliedTest.java +++ b/engine/src/test/java/org/hibernate/search/test/configuration/IndexWriterTuningAppliedTest.java @@ -8,8 +8,7 @@ import java.io.IOException; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.core.appender.NullAppender; import org.apache.lucene.index.IndexWriter; import org.hibernate.search.annotations.DocumentId; import org.hibernate.search.annotations.Field; @@ -17,11 +16,15 @@ import org.hibernate.search.backend.impl.lucene.AbstractWorkspaceImpl; import org.hibernate.search.spi.IndexedTypeIdentifier; import org.hibernate.search.spi.impl.PojoIndexedTypeIdentifier; +import org.hibernate.search.test.util.impl.log4j.Log4j2ConfigurationAccessor; import org.hibernate.search.testsupport.TestForIssue; import org.hibernate.search.testsupport.junit.SearchFactoryHolder; import org.hibernate.search.testsupport.junit.SkipOnElasticsearch; import org.hibernate.search.util.logging.impl.LuceneLogCategories; + +import org.junit.After; import org.junit.Assert; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -36,6 +39,7 @@ @TestForIssue(jiraKey = "HSEARCH-1508") @Category(SkipOnElasticsearch.class) // IndexWriters are specific to Lucene public class IndexWriterTuningAppliedTest { + private static final String LOGGER_NAME = LuceneLogCategories.INFOSTREAM_LOGGER_CATEGORY.getName(); @Rule public SearchFactoryHolder sfHolder = new SearchFactoryHolder( Dvd.class, Book.class ) @@ -43,13 +47,24 @@ public class IndexWriterTuningAppliedTest { .withProperty( "hibernate.search.index2.indexwriter.max_thread_states", "7" ) .withProperty( "hibernate.search.index2.indexwriter.infostream", "true" ); + private final Log4j2ConfigurationAccessor programmaticConfig = new Log4j2ConfigurationAccessor( LOGGER_NAME ); private final IndexedTypeIdentifier dvdTestType = PojoIndexedTypeIdentifier.convertFromLegacy( Dvd.class ); private final IndexedTypeIdentifier bookTestType = PojoIndexedTypeIdentifier.convertFromLegacy( Book.class ); + @Before + public void setUp() throws Exception { + // This will enable trace level on the magic category, + // which is necessary for infostreams to be actually enabled. + programmaticConfig.addAppender( NullAppender.createAppender( "LuceneTestAppender" ) ); + } + + @After + public void tearDown() throws Exception { + programmaticConfig.removeAppender(); + } + @Test public void testInfoStream() throws IOException { - //Enable trace level on the magic category: - Logger.getLogger( LuceneLogCategories.INFOSTREAM_LOGGER_CATEGORY.getName() ).setLevel( Level.TRACE ); AbstractWorkspaceImpl dvdsWorkspace = sfHolder.extractWorkspace( dvdTestType ); AbstractWorkspaceImpl booksWorkspace = sfHolder.extractWorkspace( bookTestType ); IndexWriter dvdsIndexWriter = dvdsWorkspace.getIndexWriter(); diff --git a/engine/src/test/java/org/hibernate/search/test/configuration/MultipleTypesInSingleIndexDeprecationTest.java b/engine/src/test/java/org/hibernate/search/test/configuration/MultipleTypesInSingleIndexDeprecationTest.java index a49ce2d4876..95b585294e7 100644 --- a/engine/src/test/java/org/hibernate/search/test/configuration/MultipleTypesInSingleIndexDeprecationTest.java +++ b/engine/src/test/java/org/hibernate/search/test/configuration/MultipleTypesInSingleIndexDeprecationTest.java @@ -17,7 +17,7 @@ import org.junit.Rule; import org.junit.Test; -import org.apache.log4j.Level; +import org.apache.logging.log4j.Level; import org.hamcrest.CoreMatchers; @TestForIssue(jiraKey = "HSEARCH-4336") diff --git a/engine/src/test/java/org/hibernate/search/test/configuration/NonExclusiveIndexUseDeprecationTest.java b/engine/src/test/java/org/hibernate/search/test/configuration/NonExclusiveIndexUseDeprecationTest.java index ae17e499c17..44d3ff9c799 100644 --- a/engine/src/test/java/org/hibernate/search/test/configuration/NonExclusiveIndexUseDeprecationTest.java +++ b/engine/src/test/java/org/hibernate/search/test/configuration/NonExclusiveIndexUseDeprecationTest.java @@ -19,7 +19,7 @@ import org.junit.Test; import org.junit.experimental.categories.Category; -import org.apache.log4j.Level; +import org.apache.logging.log4j.Level; import org.hamcrest.CoreMatchers; @TestForIssue(jiraKey = "HSEARCH-4336") diff --git a/engine/src/test/java/org/hibernate/search/test/util/impl/ExpectedLog4jLog.java b/engine/src/test/java/org/hibernate/search/test/util/impl/ExpectedLog4jLog.java index 1446ca22588..af19963bfb5 100644 --- a/engine/src/test/java/org/hibernate/search/test/util/impl/ExpectedLog4jLog.java +++ b/engine/src/test/java/org/hibernate/search/test/util/impl/ExpectedLog4jLog.java @@ -10,40 +10,52 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.HashSet; import java.util.List; import java.util.Set; -import org.apache.log4j.AppenderSkeleton; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.apache.log4j.spi.LoggingEvent; -import org.apache.log4j.spi.ThrowableInformation; +import org.hibernate.search.test.util.impl.log4j.LogChecker; +import org.hibernate.search.test.util.impl.log4j.LogExpectation; +import org.hibernate.search.test.util.impl.log4j.Log4j2ConfigurationAccessor; +import org.hibernate.search.test.util.impl.log4j.TestAppender; + +import org.junit.rules.TestRule; +import org.junit.runners.model.Statement; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.core.LogEvent; import org.hamcrest.CoreMatchers; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hamcrest.StringDescription; import org.hamcrest.TypeSafeMatcher; -import org.junit.rules.TestRule; -import org.junit.runners.model.Statement; -/** - * @author Yoann Rodiere - */ public class ExpectedLog4jLog implements TestRule { + private static final String DEFAULT_LOGGER_NAME = "org.hibernate.search"; + /** - * Returns a {@linkplain TestRule rule} that does not mandate any particular log to be produced (identical to - * behavior without this rule). + * @return a {@linkplain TestRule rule} targeting the logger named '{@value DEFAULT_LOGGER_NAME}', + * that originally does not mandate any particular log to be produced (identical to behavior without this rule). */ public static ExpectedLog4jLog create() { - return new ExpectedLog4jLog(); + return create( DEFAULT_LOGGER_NAME ); + } + + /** + * @return a {@linkplain TestRule rule} targeting the logger whose name is given by {@code loggerName}, + * that originally does not mandate any particular log to be produced (identical to behavior without this rule). + */ + public static ExpectedLog4jLog create(String loggerName) { + return new ExpectedLog4jLog( loggerName ); } + private final String loggerName; + private final List expectations = new ArrayList<>(); private TestAppender currentAppender; - private ExpectedLog4jLog() { + private ExpectedLog4jLog(String loggerName) { + this.loggerName = loggerName; } @Override @@ -56,7 +68,7 @@ public Statement apply(Statement base, org.junit.runner.Description description) *

* Defaults to expecting the event once or more. */ - public LogExpectation expectEvent(Matcher matcher) { + public LogExpectation expectEvent(Matcher matcher) { LogExpectation expectation = new LogExpectation( matcher ); expectations.add( expectation ); if ( currentAppender != null ) { @@ -84,7 +96,7 @@ public LogExpectation expectEvent(Level level, * @deprecated Use {@code expectEvent( matcher ).never() } */ @Deprecated - public void expectEventMissing(Matcher matcher) { + public void expectEventMissing(Matcher matcher) { expectEvent( matcher ).never(); } @@ -165,88 +177,51 @@ private Matcher containsAllStrings(String containedString, String... oth return CoreMatchers.allOf( matchers ); } - private Matcher eventLevelMatcher(Level level) { - return new TypeSafeMatcher() { + private Matcher eventLevelMatcher(Level level) { + return new TypeSafeMatcher() { @Override public void describeTo(Description description) { - description.appendText( "a LoggingEvent with " ).appendValue( level ).appendText( " level or higher" ); + description.appendText( "a LogEvent with " ).appendValue( level ).appendText( " level or higher" ); } + @Override - protected boolean matchesSafely(LoggingEvent item) { - return item.getLevel().isGreaterOrEqual( level ); + protected boolean matchesSafely(LogEvent item) { + return item.getLevel().isMoreSpecificThan( level ); } }; } - private Matcher eventThrowableMatcher(Matcher throwableMatcher) { - return new TypeSafeMatcher() { + private Matcher eventThrowableMatcher(Matcher throwableMatcher) { + return new TypeSafeMatcher() { @Override public void describeTo(Description description) { - description.appendText( "a LoggingEvent with throwable " ).appendValue( throwableMatcher ); + description.appendText( "a LogEvent with throwable " ).appendValue( throwableMatcher ); } + @Override - protected boolean matchesSafely(LoggingEvent item) { - ThrowableInformation throwableInfo = item.getThrowableInformation(); - return throwableMatcher.matches( throwableInfo == null ? null : throwableInfo.getThrowable() ); + protected boolean matchesSafely(LogEvent item) { + Throwable throwable = item.getThrown(); + return throwableMatcher.matches( throwable == null ? null : throwable ); } }; } - private Matcher eventMessageMatcher(final Matcher messageMatcher) { - return new TypeSafeMatcher() { + private Matcher eventMessageMatcher(final Matcher messageMatcher) { + return new TypeSafeMatcher() { @Override public void describeTo(Description description) { - description.appendText( "a LoggingEvent with message matching " ); + description.appendText( "a LogEvent with message matching " ); messageMatcher.describeTo( description ); } @Override - protected boolean matchesSafely(LoggingEvent item) { - return messageMatcher.matches( item.getMessage() ); + protected boolean matchesSafely(LogEvent item) { + return messageMatcher.matches( item.getMessage().getFormattedMessage() ); } }; } - private class TestAppender extends AppenderSkeleton { - private final List checkers; - - private TestAppender() { - this.checkers = new ArrayList<>(); - } - - void addChecker(LogChecker checker) { - checkers.add( checker ); - } - - @Override - public void close() { - // Nothing to clean up - } - - @Override - public boolean requiresLayout() { - return false; - } - - @Override - protected void append(LoggingEvent event) { - for ( LogChecker checker : checkers ) { - checker.process( event ); - } - } - - Set getFailingCheckers() { - Set failingCheckers = new HashSet<>(); - for ( LogChecker checker : checkers ) { - if ( !checker.areExpectationsMet() ) { - failingCheckers.add( checker ); - } - } - return failingCheckers; - } - } - private class ExpectedLogStatement extends Statement { private final Statement next; @@ -257,18 +232,19 @@ private class ExpectedLogStatement extends Statement { @Override public void evaluate() throws Throwable { - final Logger logger = Logger.getRootLogger(); - TestAppender appender = new TestAppender(); + Log4j2ConfigurationAccessor programmaticConfig = new Log4j2ConfigurationAccessor( loggerName ); + TestAppender appender = new TestAppender( "TestAppender" ); + programmaticConfig.addAppender( appender ); + for ( LogExpectation expectation : ExpectedLog4jLog.this.expectations ) { appender.addChecker( expectation.createChecker() ); } ExpectedLog4jLog.this.currentAppender = appender; - logger.addAppender( appender ); try { next.evaluate(); } finally { - logger.removeAppender( appender ); + programmaticConfig.removeAppender(); } Set failingCheckers = appender.getFailingCheckers(); if ( !failingCheckers.isEmpty() ) { @@ -285,98 +261,4 @@ private static String buildFailureMessage(Set failingCheckers) { } return description.toString(); } - - public static class LogExpectation { - private final Matcher matcher; - private Integer expectedCount; - - LogExpectation(Matcher matcher) { - this.matcher = matcher; - } - - public void never() { - times( 0 ); - } - - public void once() { - times( 1 ); - } - - public void times(int expectedCount) { - if ( this.expectedCount != null ) { - throw new IllegalStateException( "Can only set log expectations once" ); - } - this.expectedCount = expectedCount; - } - - LogChecker createChecker() { - return new LogChecker( this ); - } - - Matcher getMatcher() { - return matcher; - } - - int getMinExpectedCount() { - return expectedCount == null ? 1 : expectedCount; - } - - Integer getMaxExpectedCount() { - return expectedCount; - } - } - - public static class LogChecker { - private final LogExpectation expectation; - private int count = 0; - private List extraEvents; - - public LogChecker(LogExpectation expectation) { - this.expectation = expectation; - } - - void process(LoggingEvent event) { - if ( expectation.getMaxExpectedCount() == null && expectation.getMinExpectedCount() <= count ) { - // We don't care about events anymore, expectations are met and it won't change - return; - } - if ( expectation.getMatcher().matches( event ) ) { - ++count; - } - if ( expectation.getMaxExpectedCount() != null && count > expectation.getMaxExpectedCount() ) { - if ( extraEvents == null ) { - extraEvents = new ArrayList<>(); - } - extraEvents.add( event ); - } - } - - boolean areExpectationsMet() { - return expectation.getMinExpectedCount() <= count - && ( expectation.getMaxExpectedCount() == null || count <= expectation.getMaxExpectedCount() ); - } - - void appendFailure(Description description, String newline) { - description.appendText( newline ); - if ( count < expectation.getMinExpectedCount() ) { - description.appendText( "Expected at least " + expectation.getMinExpectedCount() + " time(s) " ); - expectation.getMatcher().describeTo( description ); - description.appendText( " but only got " + count + " such event(s)." ); - } - if ( expectation.getMaxExpectedCount() != null && expectation.getMaxExpectedCount() < count ) { - description.appendText( "Expected at most " + expectation.getMaxExpectedCount() + " time(s) " ); - expectation.getMatcher().describeTo( description ); - description.appendText( " but got " + count + " such event(s)." ); - description.appendText( " Extra events: " ); - for ( LoggingEvent extraEvent : extraEvents ) { - description.appendText( newline ); - description.appendText( "\t - " ); - description.appendText( extraEvent.getRenderedMessage() ); - } - } - } - - - } - } diff --git a/engine/src/test/java/org/hibernate/search/test/util/impl/HibernateSearchResourceLoaderTest.java b/engine/src/test/java/org/hibernate/search/test/util/impl/HibernateSearchResourceLoaderTest.java index 3fb1a1601fe..8ceea8035b6 100644 --- a/engine/src/test/java/org/hibernate/search/test/util/impl/HibernateSearchResourceLoaderTest.java +++ b/engine/src/test/java/org/hibernate/search/test/util/impl/HibernateSearchResourceLoaderTest.java @@ -42,7 +42,7 @@ public void setUp() { @Test public void testOpenKnownResource() throws Exception { // using a known resource for testing - String resource = "log4j.properties"; + String resource = "log4j2.properties"; InputStream in = resourceLoader.openResource( resource ); String resourceContent = StreamHelper.readInputStream( in ); assertNotNull( resourceContent ); diff --git a/engine/src/test/java/org/hibernate/search/test/util/impl/log4j/Log4j2ConfigurationAccessor.java b/engine/src/test/java/org/hibernate/search/test/util/impl/log4j/Log4j2ConfigurationAccessor.java new file mode 100644 index 00000000000..f9100b19cdc --- /dev/null +++ b/engine/src/test/java/org/hibernate/search/test/util/impl/log4j/Log4j2ConfigurationAccessor.java @@ -0,0 +1,53 @@ +/* + * Hibernate Search, full-text search for your domain model + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.search.test.util.impl.log4j; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.core.Appender; +import org.apache.logging.log4j.core.LoggerContext; +import org.apache.logging.log4j.core.config.Configuration; +import org.apache.logging.log4j.core.config.LoggerConfig; + +public class Log4j2ConfigurationAccessor { + + private final LoggerContext context; + private final Configuration configuration; + private final LoggerConfig logger; + + private Appender appender; + private Level originalLoggerLevel; + + public Log4j2ConfigurationAccessor(String loggerName) { + context = (LoggerContext) LogManager.getContext( false ); + configuration = context.getConfiguration(); + // Make sure the logger exists (this call is ignored if it already exists) + configuration.addLogger( loggerName, new LoggerConfig() ); + logger = configuration.getLoggerConfig( loggerName ); + } + + public void addAppender(Appender appender) { + this.appender = appender; + originalLoggerLevel = logger.getLevel(); + + logger.addAppender( appender, Level.ALL, null ); + logger.setLevel( Level.ALL ); + appender.start(); + context.updateLoggers(); + } + + public void removeAppender() { + if ( appender == null ) { + return; + } + + appender.stop(); + logger.removeAppender( appender.getName() ); + logger.setLevel( originalLoggerLevel ); + context.updateLoggers(); + } +} diff --git a/engine/src/test/java/org/hibernate/search/test/util/impl/log4j/LogChecker.java b/engine/src/test/java/org/hibernate/search/test/util/impl/log4j/LogChecker.java new file mode 100644 index 00000000000..8c51016a7fb --- /dev/null +++ b/engine/src/test/java/org/hibernate/search/test/util/impl/log4j/LogChecker.java @@ -0,0 +1,89 @@ +/* + * Hibernate Search, full-text search for your domain model + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.search.test.util.impl.log4j; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.logging.log4j.core.LogEvent; +import org.hamcrest.Description; + +public class LogChecker { + + private final LogExpectation expectation; + private volatile int count = 0; + private List matchingEvents; + private List extraEvents; + + LogChecker(LogExpectation expectation) { + this.expectation = expectation; + } + + public void appendFailure(Description description, String newline) { + description.appendText( newline ); + if ( count < expectation.getMinExpectedCount() ) { + description.appendText( "Expected at least " + expectation.getMinExpectedCount() + " time(s) " ); + expectation.getMatcher().describeTo( description ); + description.appendText( " but only got " + count + " such event(s)." ); + description.appendText( " Matching events: " ); + appendEvents( description, newline, matchingEvents ); + } + if ( expectation.getMaxExpectedCount() != null && expectation.getMaxExpectedCount() < count ) { + description.appendText( "Expected at most " + expectation.getMaxExpectedCount() + " time(s) " ); + expectation.getMatcher().describeTo( description ); + description.appendText( " but got " + count + " such event(s)." ); + description.appendText( " Extra events: " ); + appendEvents( description, newline, extraEvents ); + description.appendText( " Matching events: " ); + appendEvents( description, newline, matchingEvents ); + } + } + + void process(LogEvent event) { + if ( expectation.getMaxExpectedCount() == null && expectation.getMinExpectedCount() <= count ) { + // We don't care about events anymore, expectations are met and it won't change + return; + } + if ( expectation.getMatcher().matches( event ) ) { + processMatching( event ); + } + } + + // This must be synchronized to avoid problems when multiple threads issue log events concurrently + private synchronized void processMatching(LogEvent event) { + ++count; + if ( expectation.getMaxExpectedCount() != null && count > expectation.getMaxExpectedCount() ) { + if ( extraEvents == null ) { + extraEvents = new ArrayList<>(); + } + extraEvents.add( event.toImmutable() ); + } + else { + if ( matchingEvents == null ) { + matchingEvents = new ArrayList<>(); + } + matchingEvents.add( event.toImmutable() ); + } + } + + boolean areExpectationsMet() { + return expectation.getMinExpectedCount() <= count + && ( expectation.getMaxExpectedCount() == null || count <= expectation.getMaxExpectedCount() ); + } + + private static void appendEvents(Description description, String newline, List events) { + if ( events == null || events.isEmpty() ) { + description.appendText( "" ); + return; + } + for ( LogEvent event : events ) { + description.appendText( newline ); + description.appendText( "\t - " ); + description.appendText( event.getMessage().getFormattedMessage() ); + } + } +} diff --git a/engine/src/test/java/org/hibernate/search/test/util/impl/log4j/LogExpectation.java b/engine/src/test/java/org/hibernate/search/test/util/impl/log4j/LogExpectation.java new file mode 100644 index 00000000000..eb09aae3f5f --- /dev/null +++ b/engine/src/test/java/org/hibernate/search/test/util/impl/log4j/LogExpectation.java @@ -0,0 +1,50 @@ +/* + * Hibernate Search, full-text search for your domain model + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.search.test.util.impl.log4j; + +import org.hamcrest.Matcher; + +public class LogExpectation { + + private final Matcher matcher; + private Integer expectedCount; + + public LogExpectation(Matcher matcher) { + this.matcher = matcher; + } + + public void never() { + times( 0 ); + } + + public void once() { + times( 1 ); + } + + public void times(int expectedCount) { + if ( this.expectedCount != null ) { + throw new IllegalStateException( "Can only set log expectations once" ); + } + this.expectedCount = expectedCount; + } + + public LogChecker createChecker() { + return new LogChecker( this ); + } + + Matcher getMatcher() { + return matcher; + } + + int getMinExpectedCount() { + return expectedCount == null ? 1 : expectedCount; + } + + Integer getMaxExpectedCount() { + return expectedCount; + } +} diff --git a/engine/src/test/java/org/hibernate/search/test/util/impl/log4j/TestAppender.java b/engine/src/test/java/org/hibernate/search/test/util/impl/log4j/TestAppender.java new file mode 100644 index 00000000000..933db02bab3 --- /dev/null +++ b/engine/src/test/java/org/hibernate/search/test/util/impl/log4j/TestAppender.java @@ -0,0 +1,46 @@ +/* + * Hibernate Search, full-text search for your domain model + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.search.test.util.impl.log4j; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.appender.AbstractAppender; +import org.apache.logging.log4j.core.config.Property; + +public class TestAppender extends AbstractAppender { + + private final List checkers = new ArrayList<>(); + + public TestAppender(String name) { + super( name, null, null, true, Property.EMPTY_ARRAY ); + } + + @Override + public void append(LogEvent event) { + for ( LogChecker checker : checkers ) { + checker.process( event ); + } + } + + public void addChecker(LogChecker checker) { + checkers.add( checker ); + } + + public Set getFailingCheckers() { + Set failingCheckers = new HashSet<>(); + for ( LogChecker checker : checkers ) { + if ( !checker.areExpectationsMet() ) { + failingCheckers.add( checker ); + } + } + return failingCheckers; + } +} diff --git a/engine/src/test/java/org/hibernate/search/test/util/logging/LoggerInfoStreamTest.java b/engine/src/test/java/org/hibernate/search/test/util/logging/LoggerInfoStreamTest.java index ba7ae0e571a..593ad030c95 100644 --- a/engine/src/test/java/org/hibernate/search/test/util/logging/LoggerInfoStreamTest.java +++ b/engine/src/test/java/org/hibernate/search/test/util/logging/LoggerInfoStreamTest.java @@ -8,9 +8,6 @@ import java.util.List; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.apache.log4j.spi.LoggingEvent; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; @@ -18,6 +15,7 @@ import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.store.RAMDirectory; +import org.hibernate.search.test.util.impl.log4j.Log4j2ConfigurationAccessor; import org.hibernate.search.util.logging.impl.LoggerInfoStream; import org.hibernate.search.util.logging.impl.LuceneLogCategories; import org.junit.After; @@ -28,23 +26,24 @@ public class LoggerInfoStreamTest { - private Level hsearchLevel; - private final Logger hsearchLogger = Logger.getLogger( "org.hibernate.search" ); - private final Logger rootLogger = Logger.getRootLogger(); + private static final String LOGGER_NAME = LuceneLogCategories.INFOSTREAM_LOGGER_CATEGORY.getName(); + + private final Log4j2ConfigurationAccessor programmaticConfig; private TestAppender testAppender; + public LoggerInfoStreamTest() { + programmaticConfig = new Log4j2ConfigurationAccessor( LOGGER_NAME ); + } + @Before public void setUp() throws Exception { - testAppender = new TestAppender(); - rootLogger.addAppender( testAppender ); - hsearchLevel = hsearchLogger.getLevel(); - hsearchLogger.setLevel( Level.TRACE ); + testAppender = new TestAppender( "LuceneTestAppender" ); + programmaticConfig.addAppender( testAppender ); } @After public void tearDown() throws Exception { - rootLogger.removeAppender( testAppender ); - hsearchLogger.setLevel( hsearchLevel ); + programmaticConfig.removeAppender(); } @Test @@ -63,8 +62,8 @@ public void testEnableInfoStream() throws Exception { indexWriter.commit(); indexWriter.close(); - List loggingEvents = testAppender.searchByLoggerAndMessage( LuceneLogCategories.INFOSTREAM_LOGGER_CATEGORY.getName(), "IW:" ); + List logEvents = testAppender.searchByLoggerAndMessage( LOGGER_NAME, "IW:" ); - assertFalse( loggingEvents.isEmpty() ); + assertFalse( logEvents.isEmpty() ); } } diff --git a/engine/src/test/java/org/hibernate/search/test/util/logging/TestAppender.java b/engine/src/test/java/org/hibernate/search/test/util/logging/TestAppender.java index d6cfd41ea43..a99e96efc86 100644 --- a/engine/src/test/java/org/hibernate/search/test/util/logging/TestAppender.java +++ b/engine/src/test/java/org/hibernate/search/test/util/logging/TestAppender.java @@ -6,36 +6,43 @@ */ package org.hibernate.search.test.util.logging; -import org.apache.commons.collections.map.MultiValueMap; -import org.apache.log4j.WriterAppender; -import org.apache.log4j.spi.LoggingEvent; - import java.util.ArrayList; import java.util.Collection; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; + +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.appender.AbstractAppender; +import org.apache.logging.log4j.core.config.Property; + -public class TestAppender extends WriterAppender { +public class TestAppender extends AbstractAppender { - private final MultiValueMap eventsByLogger = new MultiValueMap(); + private final Map> eventMessagesByLogger = new LinkedHashMap<>(); + + public TestAppender(String name) { + super( name, null, null, true, Property.EMPTY_ARRAY ); + } @Override - public void append(LoggingEvent event) { + public void append(LogEvent event) { synchronized (this) { - eventsByLogger.put( event.getLoggerName(), event ); + eventMessagesByLogger.computeIfAbsent( event.getLoggerName(), ignored -> new ArrayList<>() ) + .add( event.getMessage().getFormattedMessage() ); } } - public List searchByLoggerAndMessage(String logger, String contents) { - ArrayList results = new ArrayList<>(); + public List searchByLoggerAndMessage(String logger, String contents) { + ArrayList results = new ArrayList<>(); synchronized (this) { - Collection collection = eventsByLogger.getCollection( logger ); + Collection collection = eventMessagesByLogger.get( logger ); if ( collection == null ) { return results; } - for ( Object event : collection ) { - LoggingEvent loggingEvent = (LoggingEvent) event; - if ( loggingEvent.getRenderedMessage().contains( contents ) ) { - results.add( loggingEvent ); + for ( String eventMessage : collection ) { + if ( eventMessage.contains( contents ) ) { + results.add( eventMessage ); } } } diff --git a/engine/src/test/resources/log4j.properties b/engine/src/test/resources/log4j.properties deleted file mode 100644 index 95c9908c7a1..00000000000 --- a/engine/src/test/resources/log4j.properties +++ /dev/null @@ -1,55 +0,0 @@ -### direct log messages to stdout ### -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n - -### direct messages to file hibernate.log ### -log4j.appender.file=org.apache.log4j.FileAppender -log4j.appender.file.File=hibernate.log -log4j.appender.file.layout=org.apache.log4j.PatternLayout -log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n - -### direct messages to socket - chainsaw ### -log4j.appender.socket=org.apache.log4j.net.SocketAppender -log4j.appender.socket.remoteHost=localhost -log4j.appender.socket.port=4560 -log4j.appender.socket.locationInfo=true - -### set log levels - for more verbose logging change 'info' to 'debug' ### - -log4j.rootLogger=warn, stdout -log4j.logger.org.jboss=info -#log4j.logger.com.jboss=debug - -log4j.logger.org.hibernate=info -log4j.logger.org.hibernate.search=info - -#log4j.logger.org.hibernate.search=info -#log4j.logger.org.hibernate.search.backend=debug - -### log just the SQL -#log4j.logger.org.hibernate.SQL=debug - -#log4j.logger.org.hibernate.engine.CascadingAction=debug - -### log JDBC bind parameters ### -#log4j.logger.org.hibernate.type=debug - -### log schema export/update ### -log4j.logger.org.hibernate.tool.hbm2ddl=warn - -### log cache activity ### -#log4j.logger.org.hibernate.cache=debug - -### enable the following line if you want to track down connection ### -### leakages when using DriverManagerConnectionProvider ### -#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace - -### annotation logs -#log4j.logger.org.hibernate.annotation=info -#log4j.logger.org.hibernate.cfg=info -#log4j.logger.org.hibernate.cfg.SettingsFactory=info -#log4j.logger.org.hibernate.cfg.AnnotationBinder=info -#log4j.logger.org.hibernate.cfg.AnnotationConfiguration=info -#log4j.logger.org.hibernate.cfg.Ejb3Column=info diff --git a/engine/src/test/resources/log4j2.properties b/engine/src/test/resources/log4j2.properties new file mode 100644 index 00000000000..270d3ed7aba --- /dev/null +++ b/engine/src/test/resources/log4j2.properties @@ -0,0 +1,29 @@ +### direct log messages to stdout ### +appender.stdout.type=Console +appender.stdout.name=STDOUT +appender.stdout.layout.type=PatternLayout +appender.stdout.layout.pattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n + +## Loggers +rootLogger.level=info +rootLogger.appenderRef.stdout.ref=STDOUT + +### JBoss logger +logger.jboss.name=org.jboss +logger.jboss.level=info + +### Hibernate logger +logger.hibernate.name=org.hibernate +logger.hibernate.level=info + +### Search logger +logger.search.name=org.hibernate.search +logger.search.level=info + +### Hbm2ddl logger +logger.hbm2ddl.name=org.hibernate.tool.hbm2ddl +logger.hbm2ddl.level=warn + +### Elasticsearch logger +logger.elasticsearch.name=org.elasticsearch.client +logger.elasticsearch.level=debug diff --git a/integrationtest/elasticsearch/pom.xml b/integrationtest/elasticsearch/pom.xml index 7f6c3bcb89f..a251da196ca 100755 --- a/integrationtest/elasticsearch/pom.xml +++ b/integrationtest/elasticsearch/pom.xml @@ -147,8 +147,8 @@ test - log4j - log4j + org.apache.logging.log4j + log4j-core test diff --git a/integrationtest/elasticsearch/src/test/java/org/hibernate/search/elasticsearch/test/PurgeIT.java b/integrationtest/elasticsearch/src/test/java/org/hibernate/search/elasticsearch/test/PurgeIT.java index 2b3314b74b8..a22c07d43b4 100644 --- a/integrationtest/elasticsearch/src/test/java/org/hibernate/search/elasticsearch/test/PurgeIT.java +++ b/integrationtest/elasticsearch/src/test/java/org/hibernate/search/elasticsearch/test/PurgeIT.java @@ -17,7 +17,7 @@ import javax.persistence.Inheritance; import javax.persistence.InheritanceType; -import org.apache.log4j.Level; +import org.apache.logging.log4j.Level; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.Query; import org.hibernate.Transaction; diff --git a/integrationtest/elasticsearch/src/test/resources/log4j.properties b/integrationtest/elasticsearch/src/test/resources/log4j.properties deleted file mode 100644 index 7ea01389779..00000000000 --- a/integrationtest/elasticsearch/src/test/resources/log4j.properties +++ /dev/null @@ -1,55 +0,0 @@ -### direct log messages to stdout ### -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n - -### direct messages to file hibernate.log ### -log4j.appender.file=org.apache.log4j.FileAppender -log4j.appender.file.File=hibernate.log -log4j.appender.file.layout=org.apache.log4j.PatternLayout -log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n - -### direct messages to socket - chainsaw ### -log4j.appender.socket=org.apache.log4j.net.SocketAppender -log4j.appender.socket.remoteHost=localhost -log4j.appender.socket.port=4560 -log4j.appender.socket.locationInfo=true - -### set log levels - for more verbose logging change 'info' to 'debug' ### - -log4j.rootLogger=info, stdout -log4j.logger.org.jboss=info -#log4j.logger.com.jboss=debug - -log4j.logger.org.hibernate=warn - -log4j.logger.org.hibernate.search=debug -log4j.logger.org.hibernate.search.elasticsearch.request=trace -#log4j.logger.org.hibernate.search.backend=debug - -### log just the SQL -#log4j.logger.org.hibernate.SQL=debug - -#log4j.logger.org.hibernate.engine.CascadingAction=debug - -### log JDBC bind parameters ### -#log4j.logger.org.hibernate.type=debug - -### log schema export/update ### -log4j.logger.org.hibernate.tool.hbm2ddl=warn - -### log cache activity ### -#log4j.logger.org.hibernate.cache=debug - -### enable the following line if you want to track down connection ### -### leakages when using DriverManagerConnectionProvider ### -#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace - -### annotation logs -#log4j.logger.org.hibernate.annotation=info -#log4j.logger.org.hibernate.cfg=info -#log4j.logger.org.hibernate.cfg.SettingsFactory=info -#log4j.logger.org.hibernate.cfg.AnnotationBinder=info -#log4j.logger.org.hibernate.cfg.AnnotationConfiguration=info -#log4j.logger.org.hibernate.cfg.Ejb3Column=info diff --git a/integrationtest/elasticsearch/src/test/resources/log4j2.properties b/integrationtest/elasticsearch/src/test/resources/log4j2.properties new file mode 100644 index 00000000000..270d3ed7aba --- /dev/null +++ b/integrationtest/elasticsearch/src/test/resources/log4j2.properties @@ -0,0 +1,29 @@ +### direct log messages to stdout ### +appender.stdout.type=Console +appender.stdout.name=STDOUT +appender.stdout.layout.type=PatternLayout +appender.stdout.layout.pattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n + +## Loggers +rootLogger.level=info +rootLogger.appenderRef.stdout.ref=STDOUT + +### JBoss logger +logger.jboss.name=org.jboss +logger.jboss.level=info + +### Hibernate logger +logger.hibernate.name=org.hibernate +logger.hibernate.level=info + +### Search logger +logger.search.name=org.hibernate.search +logger.search.level=info + +### Hbm2ddl logger +logger.hbm2ddl.name=org.hibernate.tool.hbm2ddl +logger.hbm2ddl.level=warn + +### Elasticsearch logger +logger.elasticsearch.name=org.elasticsearch.client +logger.elasticsearch.level=debug diff --git a/integrationtest/jms/src/test/resources/log4j.properties b/integrationtest/jms/src/test/resources/log4j.properties deleted file mode 100644 index fb4cc50d945..00000000000 --- a/integrationtest/jms/src/test/resources/log4j.properties +++ /dev/null @@ -1,54 +0,0 @@ -### direct log messages to stdout ### -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n - -### direct messages to file hibernate.log ### -log4j.appender.file=org.apache.log4j.FileAppender -log4j.appender.file.File=hibernate.log -log4j.appender.file.layout=org.apache.log4j.PatternLayout -log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n - -### direct messages to socket - chainsaw ### -log4j.appender.socket=org.apache.log4j.net.SocketAppender -log4j.appender.socket.remoteHost=localhost -log4j.appender.socket.port=4560 -log4j.appender.socket.locationInfo=true - -### set log levels - for more verbose logging change 'info' to 'debug' ### - -log4j.rootLogger=debug, stdout -log4j.logger.org.jboss=info -#log4j.logger.com.jboss=debug - -log4j.logger.org.hibernate=warn - -log4j.logger.org.hibernate.search=debug -#log4j.logger.org.hibernate.search.backend=debug - -### log just the SQL -#log4j.logger.org.hibernate.SQL=debug - -#log4j.logger.org.hibernate.engine.CascadingAction=debug - -### log JDBC bind parameters ### -#log4j.logger.org.hibernate.type=debug - -### log schema export/update ### -log4j.logger.org.hibernate.tool.hbm2ddl=warn - -### log cache activity ### -#log4j.logger.org.hibernate.cache=debug - -### enable the following line if you want to track down connection ### -### leakages when using DriverManagerConnectionProvider ### -#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace - -### annotation logs -#log4j.logger.org.hibernate.annotation=info -#log4j.logger.org.hibernate.cfg=info -#log4j.logger.org.hibernate.cfg.SettingsFactory=info -#log4j.logger.org.hibernate.cfg.AnnotationBinder=info -#log4j.logger.org.hibernate.cfg.AnnotationConfiguration=info -#log4j.logger.org.hibernate.cfg.Ejb3Column=info diff --git a/integrationtest/jms/src/test/resources/log4j2.properties b/integrationtest/jms/src/test/resources/log4j2.properties new file mode 100644 index 00000000000..270d3ed7aba --- /dev/null +++ b/integrationtest/jms/src/test/resources/log4j2.properties @@ -0,0 +1,29 @@ +### direct log messages to stdout ### +appender.stdout.type=Console +appender.stdout.name=STDOUT +appender.stdout.layout.type=PatternLayout +appender.stdout.layout.pattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n + +## Loggers +rootLogger.level=info +rootLogger.appenderRef.stdout.ref=STDOUT + +### JBoss logger +logger.jboss.name=org.jboss +logger.jboss.level=info + +### Hibernate logger +logger.hibernate.name=org.hibernate +logger.hibernate.level=info + +### Search logger +logger.search.name=org.hibernate.search +logger.search.level=info + +### Hbm2ddl logger +logger.hbm2ddl.name=org.hibernate.tool.hbm2ddl +logger.hbm2ddl.level=warn + +### Elasticsearch logger +logger.elasticsearch.name=org.elasticsearch.client +logger.elasticsearch.level=debug diff --git a/integrationtest/jsr352/src/test/resources/log4j.properties b/integrationtest/jsr352/src/test/resources/log4j.properties deleted file mode 100644 index c129a8ced92..00000000000 --- a/integrationtest/jsr352/src/test/resources/log4j.properties +++ /dev/null @@ -1,54 +0,0 @@ -### direct log messages to stdout ### -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n - -### direct messages to file hibernate.log ### -log4j.appender.file=org.apache.log4j.FileAppender -log4j.appender.file.File=hibernate.log -log4j.appender.file.layout=org.apache.log4j.PatternLayout -log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n - -### direct messages to socket - chainsaw ### -log4j.appender.socket=org.apache.log4j.net.SocketAppender -log4j.appender.socket.remoteHost=localhost -log4j.appender.socket.port=4560 -log4j.appender.socket.locationInfo=true - -### set log levels - for more verbose logging change 'info' to 'debug' ### - -log4j.rootLogger=info, stdout -log4j.logger.org.jboss=info -#log4j.logger.com.jboss=debug - -log4j.logger.org.hibernate=warn - -log4j.logger.org.hibernate.search=debug -#log4j.logger.org.hibernate.search.backend=debug - -### log just the SQL -#log4j.logger.org.hibernate.SQL=debug - -#log4j.logger.org.hibernate.engine.CascadingAction=debug - -### log JDBC bind parameters ### -#log4j.logger.org.hibernate.type=debug - -### log schema export/update ### -log4j.logger.org.hibernate.tool.hbm2ddl=warn - -### log cache activity ### -#log4j.logger.org.hibernate.cache=debug - -### enable the following line if you want to track down connection ### -### leakages when using DriverManagerConnectionProvider ### -#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace - -### annotation logs -#log4j.logger.org.hibernate.annotation=info -#log4j.logger.org.hibernate.cfg=info -#log4j.logger.org.hibernate.cfg.SettingsFactory=info -#log4j.logger.org.hibernate.cfg.AnnotationBinder=info -#log4j.logger.org.hibernate.cfg.AnnotationConfiguration=info -#log4j.logger.org.hibernate.cfg.Ejb3Column=info diff --git a/integrationtest/jsr352/src/test/resources/log4j2.properties b/integrationtest/jsr352/src/test/resources/log4j2.properties new file mode 100644 index 00000000000..270d3ed7aba --- /dev/null +++ b/integrationtest/jsr352/src/test/resources/log4j2.properties @@ -0,0 +1,29 @@ +### direct log messages to stdout ### +appender.stdout.type=Console +appender.stdout.name=STDOUT +appender.stdout.layout.type=PatternLayout +appender.stdout.layout.pattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n + +## Loggers +rootLogger.level=info +rootLogger.appenderRef.stdout.ref=STDOUT + +### JBoss logger +logger.jboss.name=org.jboss +logger.jboss.level=info + +### Hibernate logger +logger.hibernate.name=org.hibernate +logger.hibernate.level=info + +### Search logger +logger.search.name=org.hibernate.search +logger.search.level=info + +### Hbm2ddl logger +logger.hbm2ddl.name=org.hibernate.tool.hbm2ddl +logger.hbm2ddl.level=warn + +### Elasticsearch logger +logger.elasticsearch.name=org.elasticsearch.client +logger.elasticsearch.level=debug diff --git a/integrationtest/osgi/karaf-it/pom.xml b/integrationtest/osgi/karaf-it/pom.xml index 089bf0e6048..58a9e6d016d 100644 --- a/integrationtest/osgi/karaf-it/pom.xml +++ b/integrationtest/osgi/karaf-it/pom.xml @@ -146,8 +146,8 @@ test - org.slf4j - slf4j-log4j12 + org.apache.logging.log4j + log4j-slf4j-impl test diff --git a/integrationtest/osgi/karaf-it/src/test/resources/log4j.properties b/integrationtest/osgi/karaf-it/src/test/resources/log4j.properties deleted file mode 100644 index 2a2da76d339..00000000000 --- a/integrationtest/osgi/karaf-it/src/test/resources/log4j.properties +++ /dev/null @@ -1,22 +0,0 @@ -### direct log messages to stdout ### -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n - -### direct messages to file hibernate.log ### -log4j.appender.file=org.apache.log4j.FileAppender -log4j.appender.file.File=hibernate.log -log4j.appender.file.layout=org.apache.log4j.PatternLayout -log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n - -### direct messages to socket - chainsaw ### -log4j.appender.socket=org.apache.log4j.net.SocketAppender -log4j.appender.socket.remoteHost=localhost -log4j.appender.socket.port=4560 -log4j.appender.socket.locationInfo=true - -### set log levels - for more verbose logging change 'info' to 'debug' ### - -log4j.rootLogger=warn, stdout - diff --git a/integrationtest/performance/backend/elasticsearch/src/main/resources/log4j2.properties b/integrationtest/performance/backend/elasticsearch/src/main/resources/log4j2.properties new file mode 100644 index 00000000000..43d0607c4f4 --- /dev/null +++ b/integrationtest/performance/backend/elasticsearch/src/main/resources/log4j2.properties @@ -0,0 +1,29 @@ +### direct log messages to stdout ### +appender.stdout.type=Console +appender.stdout.name=STDOUT +appender.stdout.layout.type=PatternLayout +appender.stdout.layout.pattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n + +## Loggers +rootLogger.level=info +rootLogger.appenderRef.stdout.ref=STDOUT + +### JBoss logger +logger.jboss.name=org.jboss +logger.jboss.level=info + +### Hibernate logger +logger.hibernate.name=org.hibernate +logger.hibernate.level=info + +### Search logger +logger.search.name=org.hibernate.search +logger.search.level=info + +### Elasticsearch logger +logger.elasticsearch.name=org.elasticsearch.client +logger.elasticsearch.level=info + +### Orchestration logger +logger.orchestration.name=org.hibernate.search.engine.backend.orchestration.spi +logger.orchestration.level=debug diff --git a/integrationtest/performance/backend/lucene/src/main/resources/log4j2.properties b/integrationtest/performance/backend/lucene/src/main/resources/log4j2.properties new file mode 100644 index 00000000000..dac90984de1 --- /dev/null +++ b/integrationtest/performance/backend/lucene/src/main/resources/log4j2.properties @@ -0,0 +1,21 @@ +### direct log messages to stdout ### +appender.stdout.type=Console +appender.stdout.name=STDOUT +appender.stdout.layout.type=PatternLayout +appender.stdout.layout.pattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n + +## Loggers +rootLogger.level=info +rootLogger.appenderRef.stdout.ref=STDOUT + +### JBoss logger +logger.jboss.name=org.jboss +logger.jboss.level=info + +### Hibernate logger +logger.hibernate.name=org.hibernate +logger.hibernate.level=info + +### Search logger +logger.search.name=org.hibernate.search +logger.search.level=info diff --git a/integrationtest/performance/sandbox/src/test/resources/log4j.properties b/integrationtest/performance/sandbox/src/test/resources/log4j.properties deleted file mode 100644 index fe3a81ab63f..00000000000 --- a/integrationtest/performance/sandbox/src/test/resources/log4j.properties +++ /dev/null @@ -1,25 +0,0 @@ -### direct log messages to stdout ### -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n - -### direct messages to file hibernate.log ### -log4j.appender.file=org.apache.log4j.FileAppender -log4j.appender.file.File=hibernate.log -log4j.appender.file.layout=org.apache.log4j.PatternLayout -log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n - -### direct messages to socket - chainsaw ### -#log4j.appender.socket=org.apache.log4j.net.SocketAppender -#log4j.appender.socket.remoteHost=localhost -#log4j.appender.socket.port=4560 -#log4j.appender.socket.locationInfo=true - -### set log levels - for more verbose logging change 'info' to 'debug' ### - -log4j.rootLogger=warn, stdout -log4j.logger.org.jboss=info - -log4j.logger.org.hibernate=info -log4j.logger.org.hibernate.search=info diff --git a/integrationtest/performance/sandbox/src/test/resources/log4j2.properties b/integrationtest/performance/sandbox/src/test/resources/log4j2.properties new file mode 100644 index 00000000000..270d3ed7aba --- /dev/null +++ b/integrationtest/performance/sandbox/src/test/resources/log4j2.properties @@ -0,0 +1,29 @@ +### direct log messages to stdout ### +appender.stdout.type=Console +appender.stdout.name=STDOUT +appender.stdout.layout.type=PatternLayout +appender.stdout.layout.pattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n + +## Loggers +rootLogger.level=info +rootLogger.appenderRef.stdout.ref=STDOUT + +### JBoss logger +logger.jboss.name=org.jboss +logger.jboss.level=info + +### Hibernate logger +logger.hibernate.name=org.hibernate +logger.hibernate.level=info + +### Search logger +logger.search.name=org.hibernate.search +logger.search.level=info + +### Hbm2ddl logger +logger.hbm2ddl.name=org.hibernate.tool.hbm2ddl +logger.hbm2ddl.level=warn + +### Elasticsearch logger +logger.elasticsearch.name=org.elasticsearch.client +logger.elasticsearch.level=debug diff --git a/integrationtest/spring/pom.xml b/integrationtest/spring/pom.xml index b938a791d10..51506259c14 100755 --- a/integrationtest/spring/pom.xml +++ b/integrationtest/spring/pom.xml @@ -76,11 +76,25 @@ org.springframework.boot spring-boot-starter-data-jpa + + + + org.springframework.boot + spring-boot-starter-logging + + org.springframework.boot spring-boot-starter-test test + + + + org.springframework.boot + spring-boot-starter-logging + + org.springframework.boot @@ -88,6 +102,12 @@ test + + org.apache.logging.log4j + log4j-core + test + + javax.inject diff --git a/integrationtest/spring/src/test/java/org/hibernate/search/test/integration/spring/injection/SpringInjectionIT.java b/integrationtest/spring/src/test/java/org/hibernate/search/test/integration/spring/injection/SpringInjectionIT.java index c0b04e6eef0..3a3ae04d01b 100644 --- a/integrationtest/spring/src/test/java/org/hibernate/search/test/integration/spring/injection/SpringInjectionIT.java +++ b/integrationtest/spring/src/test/java/org/hibernate/search/test/integration/spring/injection/SpringInjectionIT.java @@ -10,7 +10,6 @@ import java.util.List; import java.util.function.Function; - import javax.inject.Inject; import org.hibernate.search.test.integration.spring.injection.i18n.InternationalizedValue; @@ -18,11 +17,12 @@ import org.hibernate.search.test.integration.spring.injection.model.EntityWithSpringAwareBridgesDao; import org.hibernate.search.test.integration.spring.injection.search.NonSpringBridge; import org.hibernate.search.testsupport.TestForIssue; + +import org.junit.After; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.junit4.SpringRunner; /** @@ -30,14 +30,20 @@ */ @RunWith(SpringRunner.class) @SpringBootTest(classes = SpringInjectionITApplicationConfiguration.class) -// Use @DirtiesContext to reinitialize the database (thanks to hbm2ddl.auto) between test methods -@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD) @TestForIssue(jiraKey = "HSEARCH-1316") public class SpringInjectionIT { @Inject private EntityWithSpringAwareBridgesDao dao; + @After + public void cleanUpData() { + // we're cleaning the data manually, + // in order to have a class level application context, + // to support the job of ExpectedLog4jLog + dao.purge(); + } + @Test public void injectedFieldBridge() { Function> search = dao::searchFieldBridge; diff --git a/integrationtest/spring/src/test/java/org/hibernate/search/test/integration/spring/injection/model/EntityWithSpringAwareBridgesDao.java b/integrationtest/spring/src/test/java/org/hibernate/search/test/integration/spring/injection/model/EntityWithSpringAwareBridgesDao.java index 015649c97ff..6380240b455 100644 --- a/integrationtest/spring/src/test/java/org/hibernate/search/test/integration/spring/injection/model/EntityWithSpringAwareBridgesDao.java +++ b/integrationtest/spring/src/test/java/org/hibernate/search/test/integration/spring/injection/model/EntityWithSpringAwareBridgesDao.java @@ -43,6 +43,13 @@ public void delete(EntityWithSpringAwareBridges entity) { entityManager.remove( entity ); } + @Transactional + public void purge() { + entityManager.createQuery( "delete from " + EntityWithSpringAwareBridges.class.getName() ) + .executeUpdate(); + Search.getFullTextEntityManager( entityManager ).purgeAll( EntityWithSpringAwareBridges.class ); + } + @Transactional @SuppressWarnings("unchecked") public List searchFieldBridge(String terms) { diff --git a/orm/pom.xml b/orm/pom.xml index 6d037ee67c2..2e350ef532d 100644 --- a/orm/pom.xml +++ b/orm/pom.xml @@ -126,8 +126,8 @@ test - log4j - log4j + org.apache.logging.log4j + log4j-core test diff --git a/orm/src/test/java/org/hibernate/search/test/bridge/BridgeTest.java b/orm/src/test/java/org/hibernate/search/test/bridge/BridgeTest.java index 40bcf2616e9..085e9412c61 100644 --- a/orm/src/test/java/org/hibernate/search/test/bridge/BridgeTest.java +++ b/orm/src/test/java/org/hibernate/search/test/bridge/BridgeTest.java @@ -142,7 +142,7 @@ public void testDefaultAndNullBridges() throws Exception { result = session.createFullTextQuery( bQuery ).setProjection( "clazz" ).list(); assertEquals( "Clazz projection works", 1, result.size() ); - query = parser.parse( "char1:[" + String.valueOf( Character.MIN_VALUE ) + " TO " + String.valueOf( Character.MAX_VALUE ) + "]" ); + query = parser.parse( "char1:[" + String.valueOf( Character.MIN_VALUE ) + " TO " + String.valueOf( Character.MAX_VALUE - 2 ) + "]" ); result = session.createFullTextQuery( query ).setProjection( "char1" ).list(); assertEquals( "Null elements should not be stored, CharacterBridge is not working", 0, result.size() ); diff --git a/orm/src/test/java/org/hibernate/search/test/engine/worker/WorkerTestCase.java b/orm/src/test/java/org/hibernate/search/test/engine/worker/WorkerTestCase.java index 09a2c11e197..807a8402b3d 100644 --- a/orm/src/test/java/org/hibernate/search/test/engine/worker/WorkerTestCase.java +++ b/orm/src/test/java/org/hibernate/search/test/engine/worker/WorkerTestCase.java @@ -8,10 +8,6 @@ import java.util.concurrent.TimeUnit; -import org.apache.log4j.Level; -import org.apache.lucene.index.Term; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.TermQuery; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; @@ -29,6 +25,11 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; +import org.apache.logging.log4j.Level; +import org.apache.lucene.index.Term; +import org.apache.lucene.search.Query; +import org.apache.lucene.search.TermQuery; + /** * @author Emmanuel Bernard * @author Sanne Grinovero diff --git a/orm/src/test/java/org/hibernate/search/test/jmx/JMXDeprecationTest.java b/orm/src/test/java/org/hibernate/search/test/jmx/JMXDeprecationTest.java index 5391aa3d107..9f9a7433bf5 100644 --- a/orm/src/test/java/org/hibernate/search/test/jmx/JMXDeprecationTest.java +++ b/orm/src/test/java/org/hibernate/search/test/jmx/JMXDeprecationTest.java @@ -22,7 +22,7 @@ import org.junit.Rule; import org.junit.Test; -import org.apache.log4j.Level; +import org.apache.logging.log4j.Level; import org.hamcrest.CoreMatchers; @TestForIssue(jiraKey = "HSEARCH-4336") diff --git a/orm/src/test/resources/log4j.properties b/orm/src/test/resources/log4j.properties deleted file mode 100644 index fb4cc50d945..00000000000 --- a/orm/src/test/resources/log4j.properties +++ /dev/null @@ -1,54 +0,0 @@ -### direct log messages to stdout ### -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n - -### direct messages to file hibernate.log ### -log4j.appender.file=org.apache.log4j.FileAppender -log4j.appender.file.File=hibernate.log -log4j.appender.file.layout=org.apache.log4j.PatternLayout -log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n - -### direct messages to socket - chainsaw ### -log4j.appender.socket=org.apache.log4j.net.SocketAppender -log4j.appender.socket.remoteHost=localhost -log4j.appender.socket.port=4560 -log4j.appender.socket.locationInfo=true - -### set log levels - for more verbose logging change 'info' to 'debug' ### - -log4j.rootLogger=debug, stdout -log4j.logger.org.jboss=info -#log4j.logger.com.jboss=debug - -log4j.logger.org.hibernate=warn - -log4j.logger.org.hibernate.search=debug -#log4j.logger.org.hibernate.search.backend=debug - -### log just the SQL -#log4j.logger.org.hibernate.SQL=debug - -#log4j.logger.org.hibernate.engine.CascadingAction=debug - -### log JDBC bind parameters ### -#log4j.logger.org.hibernate.type=debug - -### log schema export/update ### -log4j.logger.org.hibernate.tool.hbm2ddl=warn - -### log cache activity ### -#log4j.logger.org.hibernate.cache=debug - -### enable the following line if you want to track down connection ### -### leakages when using DriverManagerConnectionProvider ### -#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace - -### annotation logs -#log4j.logger.org.hibernate.annotation=info -#log4j.logger.org.hibernate.cfg=info -#log4j.logger.org.hibernate.cfg.SettingsFactory=info -#log4j.logger.org.hibernate.cfg.AnnotationBinder=info -#log4j.logger.org.hibernate.cfg.AnnotationConfiguration=info -#log4j.logger.org.hibernate.cfg.Ejb3Column=info diff --git a/orm/src/test/resources/log4j2.properties b/orm/src/test/resources/log4j2.properties new file mode 100644 index 00000000000..270d3ed7aba --- /dev/null +++ b/orm/src/test/resources/log4j2.properties @@ -0,0 +1,29 @@ +### direct log messages to stdout ### +appender.stdout.type=Console +appender.stdout.name=STDOUT +appender.stdout.layout.type=PatternLayout +appender.stdout.layout.pattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n + +## Loggers +rootLogger.level=info +rootLogger.appenderRef.stdout.ref=STDOUT + +### JBoss logger +logger.jboss.name=org.jboss +logger.jboss.level=info + +### Hibernate logger +logger.hibernate.name=org.hibernate +logger.hibernate.level=info + +### Search logger +logger.search.name=org.hibernate.search +logger.search.level=info + +### Hbm2ddl logger +logger.hbm2ddl.name=org.hibernate.tool.hbm2ddl +logger.hbm2ddl.level=warn + +### Elasticsearch logger +logger.elasticsearch.name=org.elasticsearch.client +logger.elasticsearch.level=debug diff --git a/pom.xml b/pom.xml index 71a1e697ebb..046a06838e8 100644 --- a/pom.xml +++ b/pom.xml @@ -178,7 +178,7 @@ - 5.3.23.Final + 5.3.25.Final 5.0.5.Final 2.2 @@ -247,7 +247,7 @@ 10.13.1.1 1.7.25 - 1.2.16 + 2.17.1 3.3.2.Final 2.1.0.Final @@ -491,6 +491,11 @@ com.experlog xapool + + + log4j + log4j + @@ -982,17 +987,23 @@ slf4j-api ${version.org.slf4j} + - org.slf4j - slf4j-log4j12 - ${version.org.slf4j} + org.apache.logging.log4j + log4j-core + ${version.log4j} - - log4j - log4j + org.apache.logging.log4j + log4j-api ${version.log4j} + + org.apache.logging.log4j + log4j-slf4j-impl + ${version.log4j} + + org.jboss.logging jboss-logging diff --git a/serialization/avro/src/test/resources/log4j.properties b/serialization/avro/src/test/resources/log4j.properties deleted file mode 100644 index fb4cc50d945..00000000000 --- a/serialization/avro/src/test/resources/log4j.properties +++ /dev/null @@ -1,54 +0,0 @@ -### direct log messages to stdout ### -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n - -### direct messages to file hibernate.log ### -log4j.appender.file=org.apache.log4j.FileAppender -log4j.appender.file.File=hibernate.log -log4j.appender.file.layout=org.apache.log4j.PatternLayout -log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n - -### direct messages to socket - chainsaw ### -log4j.appender.socket=org.apache.log4j.net.SocketAppender -log4j.appender.socket.remoteHost=localhost -log4j.appender.socket.port=4560 -log4j.appender.socket.locationInfo=true - -### set log levels - for more verbose logging change 'info' to 'debug' ### - -log4j.rootLogger=debug, stdout -log4j.logger.org.jboss=info -#log4j.logger.com.jboss=debug - -log4j.logger.org.hibernate=warn - -log4j.logger.org.hibernate.search=debug -#log4j.logger.org.hibernate.search.backend=debug - -### log just the SQL -#log4j.logger.org.hibernate.SQL=debug - -#log4j.logger.org.hibernate.engine.CascadingAction=debug - -### log JDBC bind parameters ### -#log4j.logger.org.hibernate.type=debug - -### log schema export/update ### -log4j.logger.org.hibernate.tool.hbm2ddl=warn - -### log cache activity ### -#log4j.logger.org.hibernate.cache=debug - -### enable the following line if you want to track down connection ### -### leakages when using DriverManagerConnectionProvider ### -#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace - -### annotation logs -#log4j.logger.org.hibernate.annotation=info -#log4j.logger.org.hibernate.cfg=info -#log4j.logger.org.hibernate.cfg.SettingsFactory=info -#log4j.logger.org.hibernate.cfg.AnnotationBinder=info -#log4j.logger.org.hibernate.cfg.AnnotationConfiguration=info -#log4j.logger.org.hibernate.cfg.Ejb3Column=info diff --git a/serialization/avro/src/test/resources/log4j2.properties b/serialization/avro/src/test/resources/log4j2.properties new file mode 100644 index 00000000000..270d3ed7aba --- /dev/null +++ b/serialization/avro/src/test/resources/log4j2.properties @@ -0,0 +1,29 @@ +### direct log messages to stdout ### +appender.stdout.type=Console +appender.stdout.name=STDOUT +appender.stdout.layout.type=PatternLayout +appender.stdout.layout.pattern=%d{ABSOLUTE} (%t) %5p %c{1}:%L - %m%n + +## Loggers +rootLogger.level=info +rootLogger.appenderRef.stdout.ref=STDOUT + +### JBoss logger +logger.jboss.name=org.jboss +logger.jboss.level=info + +### Hibernate logger +logger.hibernate.name=org.hibernate +logger.hibernate.level=info + +### Search logger +logger.search.name=org.hibernate.search +logger.search.level=info + +### Hbm2ddl logger +logger.hbm2ddl.name=org.hibernate.tool.hbm2ddl +logger.hbm2ddl.level=warn + +### Elasticsearch logger +logger.elasticsearch.name=org.elasticsearch.client +logger.elasticsearch.level=debug