CCC
CCC

Reputation: 2242

How do I log output message from console in Linux?

I am running a program under console. It keep outputting debug messages on screen. If do like this,

$./myProgram >> log.txt

then I cannot see the debug message on screen, all the messages are going to the log.txt.

So, how do I log the messages into log.txt and show the debug message on screen as well?

Thanks in advance.

Upvotes: 1

Views: 1847

Answers (2)

racic
racic

Reputation: 1275

Assuming you're logging to stdout:

$./myProgram | tee log.txt

EDIT If you choose to log errors to stderr then it might be useful to call you prog like this (stderr goes to one file, stdout goes to another file and to screen):

$./myProgram 2>error_log.txt | tee output_log.txt

Upvotes: 5

thiton
thiton

Reputation: 36049

tee. (Now a bunch of characters to make the 30 character limit)

Upvotes: 1

Related Questions