JAVA-8405: reducing logging for tutorials-build-job
This commit is contained in:
+1
-1
@@ -24,7 +24,7 @@ public class HibernateUtil {
|
||||
settings.put(Environment.USER, "sa");
|
||||
settings.put(Environment.PASS, "");
|
||||
settings.put(Environment.DIALECT, "org.hibernate.dialect.HSQLDialect");
|
||||
settings.put(Environment.SHOW_SQL, "true");
|
||||
settings.put(Environment.SHOW_SQL, "false");
|
||||
settings.put(Environment.HBM2DDL_AUTO, "update");
|
||||
configuration.setProperties(settings);
|
||||
configuration.addAnnotatedClass(User.class);
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ public class HibernateUtil {
|
||||
settings.put(Environment.USER, "sa");
|
||||
settings.put(Environment.PASS, "");
|
||||
settings.put(Environment.DIALECT, "org.hibernate.dialect.HSQLDialect");
|
||||
settings.put(Environment.SHOW_SQL, "true");
|
||||
settings.put(Environment.SHOW_SQL, "false");
|
||||
settings.put(Environment.USE_SQL_COMMENTS, "true");
|
||||
settings.put(Environment.HBM2DDL_AUTO, "update");
|
||||
configuration.setProperties(settings);
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ public class CustomInterceptor extends EmptyInterceptor {
|
||||
@Override
|
||||
public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) {
|
||||
if (entity instanceof User) {
|
||||
logger.info(((User) entity).toString());
|
||||
logger.debug(entity.toString());
|
||||
}
|
||||
return super.onSave(entity, id, state, propertyNames, types);
|
||||
}
|
||||
@@ -25,7 +25,7 @@ public class CustomInterceptor extends EmptyInterceptor {
|
||||
public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object [] previousState, String[] propertyNames, Type[] types) {
|
||||
if (entity instanceof User) {
|
||||
((User) entity).setLastModified(new Date());
|
||||
logger.info(((User) entity).toString());
|
||||
logger.debug(entity.toString());
|
||||
}
|
||||
return super.onFlushDirty(entity, id, currentState, previousState, propertyNames, types);
|
||||
}
|
||||
|
||||
+1
-2
@@ -1,7 +1,5 @@
|
||||
package com.baeldung.hibernate.interceptors.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
@@ -9,6 +7,7 @@ import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import java.util.Date;
|
||||
|
||||
@Entity(name = "hbi_user")
|
||||
public class User {
|
||||
|
||||
+3
-3
@@ -42,9 +42,9 @@ public class HibernateHiloUnitTest {
|
||||
private void configureLogger() {
|
||||
BasicConfigurator.configure();
|
||||
LogManager.getLogger("org.hibernate").setLevel(Level.ERROR);
|
||||
LogManager.getLogger("org.hibernate.id.enhanced.SequenceStructure").setLevel(Level.DEBUG);
|
||||
LogManager.getLogger("org.hibernate.event.internal.AbstractSaveEventListener").setLevel(Level.DEBUG);
|
||||
LogManager.getLogger("org.hibernate.SQL").setLevel(Level.DEBUG);
|
||||
LogManager.getLogger("org.hibernate.id.enhanced.SequenceStructure").setLevel(Level.INFO);
|
||||
LogManager.getLogger("org.hibernate.event.internal.AbstractSaveEventListener").setLevel(Level.INFO);
|
||||
LogManager.getLogger("org.hibernate.SQL").setLevel(Level.INFO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
@@ -1,5 +1,8 @@
|
||||
package com.baeldung.hibernate.proxy;
|
||||
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.LogManager;
|
||||
import org.hibernate.*;
|
||||
import org.hibernate.proxy.HibernateProxy;
|
||||
import org.junit.After;
|
||||
|
||||
@@ -2,7 +2,7 @@ hibernate.connection.driver_class=org.h2.Driver
|
||||
hibernate.connection.url=jdbc:h2:mem:hilo_db;DB_CLOSE_DELAY=-1
|
||||
hibernate.connection.username=sa
|
||||
hibernate.dialect=org.hibernate.dialect.H2Dialect
|
||||
hibernate.show_sql=true
|
||||
hibernate.show_sql=false
|
||||
hibernate.hbm2ddl.auto=create-drop
|
||||
hibernate.c3p0.min_size=5
|
||||
hibernate.c3p0.max_size=20
|
||||
|
||||
@@ -5,6 +5,6 @@ hibernate.connection.autocommit=true
|
||||
jdbc.password=
|
||||
|
||||
hibernate.dialect=org.hibernate.dialect.H2Dialect
|
||||
hibernate.show_sql=true
|
||||
hibernate.show_sql=false
|
||||
hibernate.hbm2ddl.auto=create-drop
|
||||
hibernate.current_session_context_class=org.hibernate.context.internal.ThreadLocalSessionContext
|
||||
@@ -5,5 +5,5 @@ hibernate.connection.password=
|
||||
hibernate.connection.autocommit=true
|
||||
|
||||
hibernate.dialect=org.hibernate.dialect.H2Dialect
|
||||
hibernate.show_sql=true
|
||||
hibernate.show_sql=false
|
||||
hibernate.hbm2ddl.auto=validate
|
||||
+1
-1
@@ -3,7 +3,7 @@ hibernate.connection.url=jdbc:h2:mem:mydb1;DB_CLOSE_DELAY=-1
|
||||
hibernate.connection.username=sa
|
||||
hibernate.dialect=org.hibernate.dialect.H2Dialect
|
||||
|
||||
hibernate.show_sql=true
|
||||
hibernate.show_sql=false
|
||||
hibernate.hbm2ddl.auto=create-drop
|
||||
|
||||
hibernate.physical_naming_strategy=com.baeldung.hibernate.namingstrategy.CustomPhysicalNamingStrategy
|
||||
|
||||
@@ -3,5 +3,5 @@ hibernate.connection.url=jdbc:h2:mem:mydb1;DB_CLOSE_DELAY=-1
|
||||
hibernate.connection.username=sa
|
||||
hibernate.dialect=org.hibernate.dialect.H2Dialect
|
||||
|
||||
hibernate.show_sql=true
|
||||
hibernate.show_sql=false
|
||||
hibernate.hbm2ddl.auto=create-drop
|
||||
@@ -5,7 +5,7 @@ hibernate.connection.autocommit=true
|
||||
jdbc.password=
|
||||
|
||||
hibernate.dialect=org.hibernate.dialect.H2Dialect
|
||||
hibernate.show_sql=true
|
||||
hibernate.show_sql=false
|
||||
hibernate.hbm2ddl.auto=create-drop
|
||||
|
||||
hibernate.c3p0.min_size=5
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="15 seconds" debug="false">
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>[%d{ISO8601}]-[%thread] %-5level %logger - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
||||
+2
@@ -3,12 +3,14 @@ package com.baeldung;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.baeldung.boot.Application;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = Application.class)
|
||||
@TestPropertySource(properties = {"spring.jpa.show-sql=false "})
|
||||
public class SpringContextTest {
|
||||
|
||||
@Test
|
||||
|
||||
+2
@@ -7,6 +7,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.baeldung.partialupdate.model.Customer;
|
||||
@@ -16,6 +17,7 @@ import com.baeldung.partialupdate.service.CustomerService;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = PartialUpdateApplication.class)
|
||||
@TestPropertySource(properties = {"spring.jpa.show-sql=false "})
|
||||
public class PartialUpdateUnitTest {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="15 seconds" debug="false">
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>[%d{ISO8601}]-[%thread] %-5level %logger - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
<logger name="org.hibernate" level="INFO"/>
|
||||
</configuration>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="15 seconds" debug="false">
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>[%d{ISO8601}]-[%thread] %-5level %logger - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="15 seconds" debug="false">
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>[%d{ISO8601}]-[%thread] %-5level %logger - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user