dsmiley commented on code in PR #2869: URL: https://github.com/apache/solr/pull/2869#discussion_r1845676256
########## solr/test-framework/src/java/org/apache/solr/util/LogLevelTestRule.java: ########## @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.solr.util; + +import java.lang.annotation.Annotation; +import java.util.Map; +import java.util.Optional; +import org.apache.logging.log4j.Level; +import org.apache.solr.common.util.SuppressForbidden; +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; + +/** + * A JUnit {@link TestRule} that sets (and resets) the Log4j2 log level based on the {@code + * LogLevel} annotation. + */ +public class LogLevelTestRule implements TestRule { Review Comment: IMO, this is the perfect use case for a JUnit's TestRule. It takes advantage of observing the annotations that are present so that it can insert the Statement or skip it. And it works at both the class and method level with the same Statement. And it's generally useful -- I could see someone taking this into their own projects. Maybe a case could be made for putting this rule as an inner class under LogLevel, so that it's more packaged together. ########## solr/core/src/java/org/apache/solr/util/StartupLoggingUtils.java: ########## @@ -151,6 +153,11 @@ public static void shutdown() { } flushAllLoggers(); LogManager.shutdown(true); + + // re-instate original log level. + if (!INITIAL_ROOT_LOG_LEVEL.equals(getLogLevelString())) { + changeLogLevel(INITIAL_ROOT_LOG_LEVEL); + } Review Comment: The move of this re-instate / reset of the root log level into shutdown() is debatable. I was trying to reduce little details in STC/STCJ4. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org