Skip to content

Commit

Permalink
[JAVA-11892] Logging clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
hkhan committed May 21, 2022
1 parent ec41c7e commit 565d458
Show file tree
Hide file tree
Showing 14 changed files with 104 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}
Expand All @@ -30,6 +30,6 @@ public void whenGetServicesWithFilter_thenGetAllCompatibleCipherAlgorithms() {
.map(Provider.Service::getAlgorithm)
.collect(Collectors.toList());

algorithms.forEach(logger::info);
algorithms.forEach(logger::debug);
}
}
Original file line number Diff line number Diff line change
@@ -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>
22 changes: 22 additions & 0 deletions persistence-modules/hibernate-jpa/src/main/resources/log4j.xml
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions persistence-modules/hibernate-queries/src/main/resources/log4j.xml
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions persistence-modules/hibernate-queries/src/test/resources/log4j.xml
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand All @@ -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>
Expand Down

0 comments on commit 565d458

Please sign in to comment.