[JAVA-11892] Logging clean up

This commit is contained in:
Haroon Khan 2022-05-21 20:22:05 +01:00
parent 8ab490ca80
commit 1efe19f383
14 changed files with 104 additions and 13 deletions

View File

@ -17,7 +17,7 @@ public class AvailableCiphersUnitTest {
public void whenGetServices_thenGetAllCipherAlgorithms() {
for (Provider provider : Security.getProviders()) {
for (Provider.Service service : provider.getServices()) {
logger.info(service.getAlgorithm());
logger.debug(service.getAlgorithm());
}
}
}
@ -30,6 +30,6 @@ public class AvailableCiphersUnitTest {
.map(Provider.Service::getAlgorithm)
.collect(Collectors.toList());
algorithms.forEach(logger::info);
algorithms.forEach(logger::debug);
}
}

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="false" xmlns:log4j='http://jakarta.apache.org/log4j/'>
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
</layout>
</appender>
<logger name="org.hibernate" additivity="false">
<level value="ERROR" />
<appender-ref ref="console" />
</logger>
<root>
<level value="INFO" />
<appender-ref ref="console" />
</root>
</log4j:configuration>

View File

@ -5,5 +5,8 @@ hibernate.connection.autocommit=true
jdbc.password=
hibernate.dialect=org.hibernate.dialect.H2Dialect
hibernate.show_sql=true
# enable to see Hibernate generated SQL
hibernate.show_sql=false
hibernate.hbm2ddl.auto=create-drop

View File

@ -4,5 +4,7 @@ hibernate.connection.username=sa
hibernate.connection.autocommit=true
hibernate.dialect=org.hibernate.dialect.H2Dialect
hibernate.show_sql=true
# enable to see Hibernate generated SQL
hibernate.show_sql=false
hibernate.hbm2ddl.auto=create-drop

View File

@ -5,7 +5,10 @@ hibernate.connection.autocommit=true
jdbc.password=
hibernate.dialect=org.hibernate.dialect.H2Dialect
hibernate.show_sql=true
# enable to see Hibernate generated SQL
hibernate.show_sql=false
hibernate.hbm2ddl.auto=create-drop
hibernate.c3p0.min_size=5

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="false" xmlns:log4j='http://jakarta.apache.org/log4j/'>
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
</layout>
</appender>
<logger name="org.hibernate" additivity="false">
<level value="ERROR" />
<appender-ref ref="console" />
</logger>
<root>
<level value="INFO" />
<appender-ref ref="console" />
</root>
</log4j:configuration>

View File

@ -12,7 +12,7 @@
<!-- in order to debug some marshalling issues, this needs to be TRACE -->
<logger name="org.springframework.web.servlet.mvc" level="WARN" />
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>

View File

@ -5,7 +5,8 @@ hibernate.connection.autocommit=true
jdbc.password=
hibernate.dialect=org.hibernate.dialect.H2Dialect
hibernate.show_sql=true
# enable to see Hibernate generated SQL
hibernate.show_sql=false
hibernate.hbm2ddl.auto=create-drop
hibernate.c3p0.min_size=5

View File

@ -5,5 +5,6 @@ hibernate.connection.autocommit=true
jdbc.password=
hibernate.dialect=org.hibernate.dialect.H2Dialect
hibernate.show_sql=true
# enable to see Hibernate generated SQL
hibernate.show_sql=false
hibernate.hbm2ddl.auto=create-drop

View File

@ -5,7 +5,8 @@ hibernate.connection.autocommit=true
jdbc.password=
hibernate.dialect=org.hibernate.dialect.H2Dialect
hibernate.show_sql=true
# enable to see Hibernate generated SQL
hibernate.show_sql=false
hibernate.hbm2ddl.auto=create-drop
hibernate.c3p0.min_size=5

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="false" xmlns:log4j='http://jakarta.apache.org/log4j/'>
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
</layout>
</appender>
<logger name="org.hibernate" additivity="false">
<level value="ERROR" />
<appender-ref ref="console" />
</logger>
<root>
<level value="INFO" />
<appender-ref ref="console" />
</root>
</log4j:configuration>

View File

@ -22,8 +22,9 @@ public class ArticleUnitTest {
@BeforeClass
public static void setup() {
Map<String, String> properties = new HashMap<>();
properties.put("hibernate.show_sql", "true");
properties.put("hibernate.format_sql", "true");
// set these to true to see Hibernate SQL
properties.put("hibernate.show_sql", "false");
properties.put("hibernate.format_sql", "false");
emFactory = Persistence.createEntityManagerFactory("jpa-h2", properties);
em = emFactory.createEntityManager();
}

View File

@ -14,7 +14,7 @@
<property name="javax.persistence.jdbc.user" value="baeldung" />
<property name="javax.persistence.jdbc.password" value="YourPassword" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.show_sql" value="false" />
</properties>
</persistence-unit>
@ -28,7 +28,7 @@
<property name="javax.persistence.jdbc.password" value="" />
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="show_sql" value="true"/>
<property name="show_sql" value="false"/>
<property name="hibernate.temp.use_jdbc_metadata_defaults" value="false"/>
</properties>
</persistence-unit>