0

Let's say am running a Spring Boot app via CLI using java command java -Dserver.port=5743 -jar somejar.jar and I want the logs to be printed within the cli and also copy into files.

So far I could do only one at a time either on CLI or file

Tony Stark
  • 2,318
  • 1
  • 22
  • 41
kivin6866
  • 11
  • 3

2 Answers2

1

You can use the tee utility, it copies standard input to standard output, making a copy in zero or more files.

java -Dserver.port=5742 -jar somejar.jar | tee output.file

deepakchethan
  • 5,240
  • 1
  • 23
  • 33
0

I'd suggest to use Log4j with multiple appenders in your application.

Tony Stark
  • 2,318
  • 1
  • 22
  • 41
  • Thanks Tony Stark. It is definitely a helpful tip. But I wanted generic solution that supports other frameworks and languages. – kivin6866 Jun 05 '21 at 10:21
  • @kivin6866: You can use Log4j with every other framework (not only Spring Boot) and there are similar implementations in other languages. – Tony Stark Jun 05 '21 at 10:24