Skip to content

Commit 375803d

Browse files
authored
[JAVA-6005] Reduce logging (eugenp#11247)
1 parent 79e287a commit 375803d

13 files changed

Lines changed: 102 additions & 26 deletions

File tree

algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/prim/PrimUnitTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.baeldung.algorithms.prim;
22

3+
import org.junit.Test;
4+
35
import java.util.ArrayList;
46
import java.util.List;
57

6-
import org.junit.Test;
7-
88
public class PrimUnitTest {
99

1010
@Test

algorithms-searching/src/main/java/com/baeldung/algorithms/suffixtree/SuffixTree.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
import org.slf4j.LoggerFactory;
99

1010
public class SuffixTree {
11+
1112
private static final Logger LOGGER = LoggerFactory.getLogger(SuffixTree.class);
13+
1214
private static final String WORD_TERMINATION = "$";
1315
private static final int POSITION_UNDEFINED = -1;
1416
private Node root;
@@ -23,7 +25,7 @@ public SuffixTree(String text) {
2325
}
2426

2527
public List<String> searchText(String pattern) {
26-
LOGGER.info("Searching for pattern \"{}\"", pattern);
28+
LOGGER.debug("Searching for pattern \"{}\"", pattern);
2729
List<String> result = new ArrayList<>();
2830
List<Node> nodes = getAllNodesInTraversePath(pattern, root, false);
2931

@@ -41,11 +43,11 @@ public List<String> searchText(String pattern) {
4143
}
4244

4345
private void addSuffix(String suffix, int position) {
44-
LOGGER.info(">>>>>>>>>>>> Adding new suffix {}", suffix);
46+
LOGGER.debug(">>>>>>>>>>>> Adding new suffix {}", suffix);
4547
List<Node> nodes = getAllNodesInTraversePath(suffix, root, true);
4648
if (nodes.size() == 0) {
4749
addChildNode(root, suffix, position);
48-
LOGGER.info("{}", printTree());
50+
LOGGER.debug("{}", printTree());
4951
} else {
5052
Node lastNode = nodes.remove(nodes.size() - 1);
5153
String newText = suffix;
@@ -58,7 +60,7 @@ private void addSuffix(String suffix, int position) {
5860
newText = newText.substring(existingSuffixUptoLastNode.length());
5961
}
6062
extendNode(lastNode, newText, position);
61-
LOGGER.info("{}", printTree());
63+
LOGGER.debug("{}", printTree());
6264
}
6365
}
6466

algorithms-searching/src/test/java/com/baeldung/algorithms/dfs/GraphUnitTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import java.util.List;
44

5-
import com.baeldung.algorithms.dfs.Graph;
65
import org.junit.Test;
76

87
public class GraphUnitTest {

algorithms-searching/src/test/java/com/baeldung/algorithms/quadtree/QuadTreeSearchUnitTest.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import org.slf4j.LoggerFactory;
1111

1212
public class QuadTreeSearchUnitTest {
13-
13+
1414
private static final Logger LOGGER = LoggerFactory.getLogger(QuadTreeSearchUnitTest.class);
1515

1616
private static QuadTree quadTree;
@@ -20,41 +20,41 @@ public static void setUp() {
2020
Region area = new Region(0, 0, 400, 400);
2121
quadTree = new QuadTree(area);
2222

23-
float[][] points = new float[][] { { 21, 25 }, { 55, 53 }, { 70, 318 }, { 98, 302 },
23+
float[][] points = new float[][] { { 21, 25 }, { 55, 53 }, { 70, 318 }, { 98, 302 },
2424
{ 49, 229 }, { 135, 229 }, { 224, 292 }, { 206, 321 }, { 197, 258 }, { 245, 238 } };
2525

2626
for (int i = 0; i < points.length; i++) {
2727
Point point = new Point(points[i][0], points[i][1]);
2828
quadTree.addPoint(point);
2929
}
30-
LOGGER.info("\n" + quadTree.printTree(""));
31-
LOGGER.info("==============================================");
30+
LOGGER.debug("\n" + quadTree.printTree(""));
31+
LOGGER.debug("==============================================");
3232
}
3333

3434
@Test
3535
public void givenQuadTree_whenSearchingForRange_thenReturn1MatchingItem() {
3636
Region searchArea = new Region(200, 200, 250, 250);
3737
List<Point> result = quadTree.search(searchArea, null, "");
38-
LOGGER.info(result.toString());
39-
LOGGER.info(quadTree.printSearchTraversePath());
40-
38+
LOGGER.debug(result.toString());
39+
LOGGER.debug(quadTree.printSearchTraversePath());
40+
4141
Assert.assertEquals(1, result.size());
42-
Assert.assertArrayEquals(new float[] { 245, 238 },
42+
Assert.assertArrayEquals(new float[] { 245, 238 },
4343
new float[]{result.get(0).getX(), result.get(0).getY() }, 0);
4444
}
45-
45+
4646
@Test
4747
public void givenQuadTree_whenSearchingForRange_thenReturn2MatchingItems() {
4848
Region searchArea = new Region(0, 0, 100, 100);
4949
List<Point> result = quadTree.search(searchArea, null, "");
50-
LOGGER.info(result.toString());
51-
LOGGER.info(quadTree.printSearchTraversePath());
52-
50+
LOGGER.debug(result.toString());
51+
LOGGER.debug(quadTree.printSearchTraversePath());
52+
5353
Assert.assertEquals(2, result.size());
54-
Assert.assertArrayEquals(new float[] { 21, 25 },
54+
Assert.assertArrayEquals(new float[] { 21, 25 },
5555
new float[]{result.get(0).getX(), result.get(0).getY() }, 0);
56-
Assert.assertArrayEquals(new float[] { 55, 53 },
56+
Assert.assertArrayEquals(new float[] { 55, 53 },
5757
new float[]{result.get(1).getX(), result.get(1).getY() }, 0);
58-
58+
5959
}
6060
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<Configuration status="WARN">
4+
<Appenders>
5+
<Console name="Console" target="SYSTEM_OUT">
6+
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
7+
</Console>
8+
</Appenders>
9+
<Loggers>
10+
<Logger name="org.apache.meecrowave" level="warn">
11+
<AppenderRef ref="Console"/>
12+
</Logger>
13+
14+
<Root level="info">
15+
<AppenderRef ref="Console"/>
16+
</Root>
17+
</Loggers>
18+
</Configuration>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
# Set everything to be logged to the console
19+
log4j.rootCategory=WARN, console
20+
log4j.appender.console=org.apache.log4j.ConsoleAppender
21+
log4j.appender.console.target=System.err
22+
log4j.appender.console.layout=org.apache.log4j.PatternLayout
23+
log4j.appender.console.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n
24+
25+
# Set the default spark-shell log level to WARN. When running the spark-shell, the
26+
# log level for this class is used to overwrite the root logger's log level, so that
27+
# the user can have different defaults for the shell and regular Spark apps.
28+
log4j.logger.org.apache.spark.repl.Main=WARN
29+
30+
# Settings to quiet third party logs that are too verbose
31+
log4j.logger.org.spark_project.jetty=WARN
32+
log4j.logger.org.spark_project.jetty.util.component.AbstractLifeCycle=ERROR
33+
log4j.logger.org.apache.spark.repl.SparkIMain$exprTyper=INFO
34+
log4j.logger.org.apache.spark.repl.SparkILoop$SparkILoopInterpreter=INFO
35+
36+
# SPARK-9183: Settings to avoid annoying messages when looking up nonexistent UDFs in SparkSQL with Hive support
37+
log4j.logger.org.apache.hadoop.hive.metastore.RetryingHMSHandler=FATAL
38+
log4j.logger.org.apache.hadoop.hive.ql.exec.FunctionRegistry=ERROR
39+
40+
# Parquet related logging
41+
log4j.logger.org.apache.parquet.CorruptStatistics=ERROR
42+
log4j.logger.parquet.CorruptStatistics=ERROR

core-java-modules/core-java-io/src/main/resources/logback.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
<logger name="org.springframework" level="WARN" />
1111
<logger name="org.springframework.transaction" level="WARN" />
12+
<logger name="net.sf.jmimemagic" level="WARN" />
1213

1314
<!-- in order to debug some marshalling issues, this needs to be TRACE -->
1415
<logger name="org.springframework.web.servlet.mvc" level="WARN" />

core-java-modules/core-java-jar/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
<plugin>
7777
<groupId>org.apache.maven.plugins</groupId>
7878
<artifactId>maven-dependency-plugin</artifactId>
79+
<version>${maven-dependency-plugin.version}</version>
7980
<executions>
8081
<execution>
8182
<id>copy-dependencies</id>
@@ -106,6 +107,7 @@
106107
<plugin>
107108
<groupId>org.apache.maven.plugins</groupId>
108109
<artifactId>maven-assembly-plugin</artifactId>
110+
<version>${maven-assembly-plugin.version}</version>
109111
<executions>
110112
<execution>
111113
<phase>package</phase>
@@ -383,6 +385,8 @@
383385
<maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
384386
<onejar-maven-plugin.version>1.4.4</onejar-maven-plugin.version>
385387
<maven-shade-plugin.version>3.1.1</maven-shade-plugin.version>
388+
<maven-assembly-plugin.version>3.3.0</maven-assembly-plugin.version>
389+
<maven-dependency-plugin.version>3.2.0</maven-dependency-plugin.version>
386390
<spring-boot-maven-plugin.version>2.0.3.RELEASE</spring-boot-maven-plugin.version>
387391
<source.version>1.8</source.version>
388392
<target.version>1.8</target.version>

jee-7/src/main/resources/logback.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
</encoder>
88
</appender>
99

10+
<logger name="org.jboss.weld" level="WARN" />
11+
1012
<root level="INFO">
1113
<appender-ref ref="STDOUT" />
1214
</root>
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
spring.jpa.properties.hibernate.jdbc.batch_size=4
22
spring.jpa.properties.hibernate.order_inserts=true
33
spring.jpa.properties.hibernate.order_updates=true
4-
spring.jpa.properties.hibernate.generate_statistics=true
54

65
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
76

0 commit comments

Comments
 (0)