jeudi 25 juin 2015

How can to add log in test (spring boot)?

I want to add logging (for console) in my project, in test part by spring boot. I have my test:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {TestConfig.class})
public class MyTest {

    private final static org.slf4j.Logger LOGGER = LoggerFactory.getLogger(MyTest.class);

    @Autowired
    public UserDao userDao;

    @Test
    public void test1() {
        LOGGER.info("info test");
        LOGGER.debug("debug test");
    }
}

and my test config:

@Configuration
@EnableJpaRepositories("example.dao")
@ComponentScan(basePackageClasses = { MyServiceImpl.class})
@EntityScan({"example.model"})
@Import({DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
public class TestConfig {

}

I create application.properties file in test/resource. And Gradle see my resource folder as resource for tests. My application.properties:

logging.level.= INFO
logging.level.tests.= INFO
logging.level.org.hibernate= INFO
logging.level.org.springframework= INFO
logging.level.org.apache.cxf= INFO

But when I run my test, I have:

16:59:17.593 [main] INFO  tests.MyTest - info test
16:59:17.594 [main] DEBUG tests.MyTest - debug test

in console, why? I set just 'INFO'(logging.level.= INFO), Why 'DEBUG' in console? How can to set just 'INFO'?

Aucun commentaire:

Enregistrer un commentaire