0

I'm learning book Spring In Action 4th. And I read chapter2.

When I finished my first demo in chapter2, I found some problem. There are too much debug info when junit start.

Too much debug info

I do not know how to limit the output of junit. I tried to add a application.yml in src/test/resources folder, but it doesn't work.

Can someone give me some advice about how to control the level of log information in junit?

If you want to see my code, you can download my code from Github.

My project use SpringBoot and Gradle.

hellozjf
  • 169
  • 5
  • 16
  • 1
    All right. I have ask the wrong question. My question have been asked in https://stackoverflow.com/questions/35232827/spring-boot-test-ignores-logging-level. Sorry for asking this question. – hellozjf Nov 29 '17 at 00:45
  • No need to apologize. There are thousands of engineers all solving similar problems! We're going to have the same questions from time to time. – Freiheit Nov 29 '17 at 02:12

1 Answers1

1

Create application-test.properties inside src/main/resources and set logging level INFO

logging.level.root=INFO

and use @ActiveProfiles("test") in your Test class

ex:

@RunWith(SpringRunner.class)
@SpringBootTest
@ActiveProfiles("test")
public class Chapter2ApplicationTests

Also if you want change logging level in application level for all profile then change in application.yml

logging:
  level:
    root: info
soundsystem: info
Bhushan Uniyal
  • 5,575
  • 2
  • 22
  • 45