sorin
sorin

Reputation: 170340

How to log maven output to a file and without hiding console?

I want to save maven output to a file, but without loosing the output to console. Usage of tee is not an option because I run under Windows and also I do not want to add a binary tee.exe to the source tree.

Upvotes: 20

Views: 59061

Answers (7)

Vishnu
Vishnu

Reputation: 1009

Maven 3 command output can be redirected now. See the below command on windows:

mvn -X install  > test.log

This will redirect the command output to test.log file ,located in the current directory.

Upvotes: 7

Dave Baghdanov
Dave Baghdanov

Reputation: 2358

Since you said you're on windows. In powershell there is the Tee-Object. I run maven as such: (note that in powershell you'll need to enclose the whole -Dexec.args in quotes).

mvn exec:java "-Dexec.mainClass=com.proj.main" "-Dexec.args=arg0 arg1" | Tee-Object -FilePath output.log

Upvotes: 3

some_random_guy
some_random_guy

Reputation: 21

use a tail command tail -f log_file_name in another console.

Upvotes: 2

Varun
Varun

Reputation: 4452

If you are using linux. you can use the bellow command. mvn install -X | tee log.txt

Upvotes: 11

Shailesh Pratapwar
Shailesh Pratapwar

Reputation: 4224

Use Powercmd. It works as like normal command prompt plus some additional features like automatically log everything on screen, multiple windows, shortcuts.

Upvotes: 2

sorin
sorin

Reputation: 170340

As of today, maven2 does not supports this.

Upvotes: 3

wr1472
wr1472

Reputation: 21

Use :

> file-name

at the end of your mvn command to send output to a file then use something like wintail to tail the file.

Upvotes: 2

Related Questions