Hemant
Hemant

Reputation: 63

Embedded Linux -> saving application logs to File

You may see the question as a duplicate, but please read till the end.

I have an application running on the embedded Linux and I want to capture all the logs from the application. I tried with the with file descriptors as 1 for stdout and 2 for stderr. I was able to capture stderr logs. I want to capture the logs with the printf statement. The application is already built so I can not change it. It is embedded Linux so it does not have script utility. My application have printf logs. All I want is to capture them using shell command if any. I have tried below commands

./application 2>&1 | tee file.txt
./application >cmd.log 2>&1
./application | tee log.txt

With these commands I was able to capture error messages but not the printf messages

Please help.

Upvotes: 0

Views: 487

Answers (1)

tofro
tofro

Reputation: 6063

Your first two command lines should actually catch everything that is sent (via printf, puts, whatever) to stdin and stderr (the last command line misses the latter).

If there are still messages printed to the console or tty, the application either redirects (using dup2, for example) stderr and/or stdout to some other device or it doesn't send its output to these two FILEs at all (glibc, for example, is known to write directly to the console device in certain error cases).

Without knowing where that output is actually sent to, it's impossible to catch it. straceing the application could be used to find out where these strings are being sent to.

Upvotes: 1

Related Questions