Page 1 of 1

get errors to a file

Posted: 3. Feb 2015, 15:36
by dinodin
Hello, I'm using Virtual Box 4.1.2.
I'm runing vboxManage.exe to run vBox command from another application with scripts.

Sometime the command return an error (Like when I am trying to start a machine whice does not exist).

I know that the error is log in a log file in the current user directory.

Is there a way to redirect the errors to a specific file?

Thanks,
Roy

Re: get errors to a file

Posted: 3. Feb 2015, 19:00
by socratis
dinodin wrote:I know that the error is log in a log file in the current user directory.
How do you know that? Did you do it in the scripts? In any case, that doesn't sound like a VirtualBox problem to me, but maybe I'm wrong. I mean if your script was trying to control MySQL as well, would you be asking here, in the MySQL forums or (IMO) in the forums of your operating system? I'd say the latter...

Re: get errors to a file

Posted: 3. Feb 2015, 19:33
by scottgus1
Sure enough, the Vboxmanage errors do show up in the VboxSVC.log. I ran a test command "Vboxmanage startvm testme" where testme is not a valid guest name, and got this line in VboxSVC.log:

Code: Select all

29:07:32.562000          ERROR [COM]: aRC=VBOX_E_OBJECT_NOT_FOUND (0x80bb0001) aIID={3b2f08eb-b810-4715-bee0-bb06b9880ad2} aComponent={VirtualBox} aText={Could not find a registered machine named 'testme'}, preserve=false
As for redirecting that error to a different file, I would guess that's not likely to be possible. I haven't come across anything like that in the user manual. (Could have missed it though, it's a big manual)

You're likely going to have to run tests on your commands within your scripts to see, as an example, if the guest you're about to run exists or not.

fwiw, windows command files can redirect the output of commands to disk files using the greater-than symbol, like "dir > myfile.txt" will put the directory listing in myfile.txt instead of showing it on the screen. But Vboxmanage doesn't use that redirecting function for its error output, as I've seen.

Re: get errors to a file

Posted: 3. Feb 2015, 20:11
by socratis
First, the output that you see in your mistaken command is the the 'standard output' (stdout), it is the 'standard error' (stderr). Well, in *nix you could redirect the output of stderr easily with something like:
VBoxManage startvm notavail 2>> ErrorLog.txt
The '2>>' takes the stderr (2) and appends it (>>) to a filed called ErrorLog.txt. It works just fine with VBoxManage. I'll look if there's something analogous for Windows and report back. That would solve the OP's problem, right? That's what I had in mind at the beginning in any event.

Re: get errors to a file

Posted: 3. Feb 2015, 20:36
by socratis
Hey, guess what, Microsoft has the same feature! http://support.microsoft.com/kb/110930

Re: get errors to a file

Posted: 4. Feb 2015, 10:42
by dinodin
socratis wrote:Hey, guess what, Microsoft has the same feature! http://support.microsoft.com/kb/110930
Hi socratis,

Thats great, Thanks.
Redirecting useing the 2> writes the error to my own log file and also to the vBox log file.

Thats exactly what I wanted!

Thanks again.

Roy.

Re: get errors to a file

Posted: 4. Feb 2015, 10:51
by socratis
That's great! I learned something in the process as well. I knew about the *nix world, now I know about Windows as well.