Killeroo / PowerPing

Advanced command-line ping tool
MIT License
199 stars 29 forks source link

Log to file #116

Closed n3t closed 9 months ago

n3t commented 4 years ago

Hi,

I tried to redirect stdoutput to file like this powerping 127.0.0.1 > test.log It stores the file correctly, however the process ends up with an exception

Unhandled exception: System.IO.IOException: The handle is invalid.

   v System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   v System.Console.set_CursorVisible(Boolean value)
   v PowerPing.Program.Main(String[] args)

However, would be nice to have option to store some log file, even, for example, when using graph. So I can have graph on the screen and detailed log in file.

Pavel

Killeroo commented 4 years ago

Good idea, I think this is an especially important feature if normal pipe redirection is broken. I will see if I can add this to the next release.

n3t commented 4 years ago

Thanks :)

Killeroo commented 4 years ago

@n3t This exception is now fixed in the latest release (download it here), PowerPing's output should be able to piped to a file or just generally have it's output redirected without producing an error.

I still like the idea of maybe writing to a log file while still outputting to the console so will look to add that in the next big release.

MortenMacFly commented 3 years ago

May I add that additionally to redirection a proper (e.g. CSV formatted) log file would be greatly appreciated. I am thinking of the use-case to monitor for quite some time and to analyse statistics afterwards... Here, a CSV file would be perfect.

Thank you!

Killeroo commented 3 years ago

Good idea @MortenMacFly, I have bumped it to the top of my todo list for the next release 👍

MortenMacFly commented 3 years ago

Nice, glad you like it. BTW: The coloured output is extremely helpful compared to standard-ping!

asjones987 commented 3 years ago

I could not get this to output to a file.... what am I missing?

powerping --fulltimestamp -infinite www.google.com > testping.txt

i should add it created the file but it was empty. I did have to use CTRL-C to stop as i am using infinite.

Killeroo commented 3 years ago

@asjones987 Your arguments seem fine, I tried it out locally and did manage to get it to work. I found that initially it seemed like it wasn't working until I specified the full path of the log file (... > E:\testping.txt), then it seemed to start working again even without the full path.

But the argument is valid so I am not quite sure why it might not be working.

asjones987 commented 3 years ago

ooops i forgot to respond.... i found that if i run a comment prompt as Admin then I don't have the issue. The only side issue still is one does not get to see anything on the screen while it is running.

Ideally it would be nice if instead of having to redirect to a file there was a parameter like -File:<path/name> that would write to a file and also have the display in the command prompt window. So one could visually see everything AND have a clean log at the same time.

thanks for the help and keep up with the good work.

Alan

Killeroo commented 9 months ago

I've added basic dedicated log support in the newest release. You can find it here: https://github.com/Killeroo/PowerPing/releases/tag/v1.3.4