How to write stdout statement in .log file in spring boot application

  • I am trying to write a System.out.print statement in a log file

  • I am using the following application.properties file

logging.level.org.springframework.web = INFO

logging.level.org.hibernate = ERROR

logging.level.com.cirq.configurator = INFO

logging.path = $ {mypath}

logging.file = filename.log

  • But using the code above, I cannot write the System.out.print statement in the log file
  • First, I create a .jar file for my spring-boot project and run it on the application server
  • Please help me .... Thanks in advance
+7
java spring-boot logging
source share
1 answer

if you deploy the .jar file on the application server, the System.out.print statement will not work (which means it will not be written to the log file).

For this you need to use log4j, which is built into Spring Boot.

Example:

final static Logger logger = LoggerFactory.getLogger (YourController.class);

logger.info ("Your print request");

Refer link

+6
source share

All Articles