Skip to content

Commit 04ca57a

Browse files
committed
4_4_HW3_fix_logging
1 parent a46fe82 commit 04ca57a

4 files changed

Lines changed: 10 additions & 13 deletions

File tree

‎src/main/resources/spring/spring-db.xml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66

77
<context:property-placeholder location="classpath:db/postgres.properties" system-properties-mode="OVERRIDE"/>
88

9+
<!--
10+
For postgres driver logging
11+
It uses java.util.logging and logged via jul-to-slf4j bridge
12+
https://stackoverflow.com/a/27296470/548473
13+
-->
14+
<bean class="org.springframework.beans.factory.config.MethodInvokingBean">
15+
<property name="staticMethod" value="org.slf4j.bridge.SLF4JBridgeHandler.install" />
16+
</bean>
17+
918
<!--no pooling-->
1019
<bean id="dataSource"
1120
class="org.springframework.jdbc.datasource.DriverManagerDataSource">

‎src/test/java/ru/javawebinar/topjava/service/MealServiceTest.java‎

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

33
import org.junit.Test;
44
import org.junit.runner.RunWith;
5-
import org.slf4j.bridge.SLF4JBridgeHandler;
65
import org.springframework.beans.factory.annotation.Autowired;
76
import org.springframework.dao.DataAccessException;
87
import org.springframework.test.context.ContextConfiguration;
@@ -28,10 +27,6 @@
2827
@Sql(scripts = "classpath:db/populateDB.sql", config = @SqlConfig(encoding = "UTF-8"))
2928
public class MealServiceTest {
3029

31-
static {
32-
SLF4JBridgeHandler.install();
33-
}
34-
3530
@Autowired
3631
private MealService service;
3732

‎src/test/java/ru/javawebinar/topjava/service/UserServiceTest.java‎

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

33
import org.junit.Test;
44
import org.junit.runner.RunWith;
5-
import org.slf4j.bridge.SLF4JBridgeHandler;
65
import org.springframework.beans.factory.annotation.Autowired;
76
import org.springframework.dao.DataAccessException;
87
import org.springframework.test.context.ContextConfiguration;
@@ -27,12 +26,6 @@
2726
@Sql(scripts = "classpath:db/populateDB.sql", config = @SqlConfig(encoding = "UTF-8"))
2827
public class UserServiceTest {
2928

30-
static {
31-
// Only for postgres driver logging
32-
// It uses java.util.logging and logged via jul-to-slf4j bridge
33-
SLF4JBridgeHandler.install();
34-
}
35-
3629
@Autowired
3730
private UserService service;
3831

‎src/test/resources/logback-test.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</appender>
1313

1414
<logger name="org.postgresql" level="debug"/>
15-
<logger name="org.springframework.jdbc" level="debug"/>
15+
<logger name="org.springframework.jdbc" level="info"/>
1616
<logger name="ru.javawebinar.topjava" level="debug"/>
1717

1818
<root level="INFO">

0 commit comments

Comments
 (0)