Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

  • I use 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 above code, I am not able to write System.out.print statement in the log file
  • First, I create .jar file of my spring-boot project and run in undertow application server
  • Please help me.... Thanks in advance
like image 237
Pranay Kumbhalkar Avatar asked Feb 27 '17 10:02

Pranay Kumbhalkar


People also ask

How do I specify a logging file in spring boot?

By default, Spring Boot will only log to the console and will not write log files. If you want to write log files in addition (emphasis added) to the console output you need to set a logging. file or logging. path property (for example in your application.

What is stdout in logs?

The stdout. log file is a console logging file that has poor log management which causes the file to grow too large. PROBLEM DESCRIPTION. From PingFederate 9.0 onwards: 1) If an OS service start up script is being used or <pfinstall>/sbin/pingfederate-run.sh, output can be sent to stdout.


1 Answers

if you are deploying .jar file in undertow application server, then System.out.print statement will not work(means it will not write in log file).

For that you have to use log4j which is in-built in Spring Boot.

Example:

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

logger.info("Your print statement");

Refer link

like image 180
Satish Kr Avatar answered Oct 18 '22 10:10

Satish Kr