Home > Blockchain >  To print myApp name in Springboot logging
To print myApp name in Springboot logging

Time:07-28

I have a springboot application which prints random logs. I also want to include myApp name in those logs. How to do that?

CodePudding user response:

Add properties listed below to your application.properties and application name will be appended to all your logs:

spring.application.name=my-spring-boot-application
logging.pattern.level= %5p [${spring.application.name}]

CodePudding user response:

In your application.properties you configured the name with:

spring.application.name=your-app-name

Then you can just Autowire it in with:

@Value("${spring.application.name}")
private String applicationName;

And then finally just log it:

 LOGGER.info("Your application name: {}", applicationName);
  • Related