title: Spring Data doesn't log findById
body: <p>Having created a <code>Customer</code> entity and repository:</p>
  
  <pre><code>public interface CustomerRepository extends CrudRepository&lt;Customer, Long&gt; {
  }
  </code></pre>
  
  <p>and bean that saves and selects an entity:</p>
  
  <pre><code>@Component
  public class BeanClass
  {
    @Autowired
    CustomerRepository repository;
  
    @Transactional
    public void tran()
    {
      Customer entity = new Customer("Jack3", "Bauer");
      Customer save1 = repository.save(entity);
      Optional&lt;Customer&gt; byId = repository.findById(Long.valueOf(save1.getId()));
      System.out.println("customer " + byId);
    }
  }
  </code></pre>
  
  <p>I specified query logging <code>logging.level.org.hibernate.SQL=TRACE</code> in configuration:</p>
  
  <pre><code>spring.datasource.url=jdbc:mysql://localhost/demospring?useUnicode=true&amp;useJDBCCompliantTimezoneShift=true&amp;useLegacyDatetimeCode=false&amp;serverTimezone=UTC
  spring.datasource.username=*
  spring.datasource.password=*
  spring.datasource.driver-class-name=com.mysql.jdbc.Driver
  spring.jpa.generate-ddl=true
  spring.jpa.hibernate.ddl-auto = update
  logging.level.org.hibernate.SQL=TRACE
  log4j.logger.org.springframework.transaction=DEBUG
  log4j.logger.org.springframework.orm.jpa=DEBUG
  </code></pre>
  
  <p>I don't see <code>select</code> query in logs, there's only logging of the entity being persisted:</p>
  
  <pre><code>2019-12-28 16:29:56.732  INFO 17623 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
  2019-12-28 16:29:57.331  INFO 17623 --- [           main] com.example.demo.DemoApplication         : Started DemoApplication in 4.526 seconds (JVM running for 5.198)
  2019-12-28 16:29:57.382 DEBUG 17623 --- [           main] org.hibernate.SQL                        : insert into customer (first_name, last_name) values (?, ?)
  customer Optional[Customer[id=73, firstName='Jack3', lastName='Bauer']]
  2019-12-28 16:30:03.455  INFO 17623 --- [       Thread-2] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
  2019-12-28 16:30:03.457  INFO 17623 --- [       Thread-2] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
  2019-12-28 16:30:03.462  INFO 17623 --- [       Thread-2] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
  </code></pre>
  
  <p>This is the main class:</p>
  
  <pre><code>
  @SpringBootApplication
  public class DemoApplication
  {
    private static final Logger log = LoggerFactory.getLogger(DemoApplication.class);
  
    public static void main(String[] args)
    {
      SpringApplication.run(DemoApplication.class, args);
    }
    @Autowired
    BeanClass bc;
    @Bean
    public CommandLineRunner demo(CustomerRepository repository)
    {
  
      return (args) -&gt; {
        bc.tran();
      };
    }
  }
  </code></pre>
  
  <p>Can <code>findById</code> be logged?</p>