Lost
Lost

Reputation: 349

How do we save logs while building the code?

I am building code in C using make , how would I save build logs ?

Upvotes: 2

Views: 4472

Answers (7)

Anton Kovalenko
Anton Kovalenko

Reputation: 21517

In addition to redirection proposed by another answers, consider the script utility which writes the complete log of your interaction with a shell and its children or with another program: both input and output.

Sometimes you have to intervene during make, fix something in place when it fails, restart again. When a thing like that is done in a hurry, it's beneficial to have a protocol of what you've done without having to think of logging or recording when you do it.

Upvotes: 0

Raghu Srikanth Reddy
Raghu Srikanth Reddy

Reputation: 2711

make 2>&1 > output.log

This will help you

Upvotes: 0

Rerito
Rerito

Reputation: 6086

If you use standard make, I assume you do it through a terminal, so you would only have to do : make >> mylogfile.log.
For more tricks about I/O redirection, take a look here.

Upvotes: 1

mstrewe
mstrewe

Reputation: 416

If you want to save the output of make then use:

make 1>std.out 2> err.out

The 1 means the standardoutput and 2 the erroroutput

Upvotes: 1

sheu
sheu

Reputation: 5763

Shell output redirection will help you here.

make 2>&1 > output.log

See: make output redirection

Upvotes: 2

Some programmer dude
Some programmer dude

Reputation: 409442

If you both want to save the log and see it on the console, you could use the tee command:

make 2>&1 | tee build.log

The 2>&1 part is telling the shell to redirect stderr to stdout.

Upvotes: 7

unwind
unwind

Reputation: 400069

Typically the most interesting output (compiler warnings and errors) goes to stderr. In bash:

$ make 2> out

Then inspect the file nameed out. The 2> is a Bash output redirection operator.

Upvotes: 2

Related Questions