Blank log file when run from command line

Asked by JayG

***************************** possible solutions
Since you do not see anything in the logfile, you are using simple print statements for your "logging" and not the features as described here: http://sikulix-2014.readthedocs.io/en/latest/scripting.html#writing-and-redirecting-log-and-debug-messages (which is the kind of logging, as it is used in SikuliX).

the print statement's output in the standard goes to stdout, which in turn in the IDE is per default redirected to the message area.
see: http://sikulix-2014.readthedocs.io/en/latest/faq/010-command-line.html
and the option -c to start the IDE from a commandline and switch off the message box, so all print output goes to stdout (commandline), which in turn can be redirected to a file using > (as you already did for a scriptrun).

you might also use the print statement to directly print to a file:
fLog = open(fnameLog, "w")
print >> fLog, "print test"
fLog.close()

where fnameLog is a valid filename string, that might be formed using os.path.join()
all this is standard Python

------------------------------------------------------------------------------

hi kinda new at this and testing some log outputs. When using the IDE with the Settings.LogTime the message area displays perfectly. When I try to redirect that output to a simple txt it's a blank file, even the default non-specificed "WorkingDir/SikuliLog.txt" is blank. any options that I am missing?

EDIT: I should mention im using 1.1.0 for now on a WIN 10 machine

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

--- When I try to redirect that output to a simple txt ...
... please specify exactly how you do that

BTW: recommended to use version 1.1.1 anyways (http://sikulix.com )

Revision history for this message
JayG (jguajardo) said :
#2

I was redirecting with
C:\Sikuli\runsikuli.cmd -r C:\Users\Test\Documents\SikuliTests\test1.sikuli -f C:\Users\Test\Desktop\testLog1.txt
which was blank. So was
C:\Sikuli\runsikuli.cmd -f -r C:\Users\Test\Documents\SikuliTests\test1.sikuli
which I believe is supposed to go to "WorkingDir/SikuliLog.txt"
which was also blank. So I just took the console output and did
C:\Sikuli\runsikuli.cmd -r "C:\Users\Test\Documents\SikuliTests\test1.sikuli" > C:\Users\Test\Desktop\testLog1.txt
which seems to work for what I need.
Also is there a way to direct the IDE message window to a log file at the same time that I dont know about?

Thanks
Jay

I'm switching to 1.1.1 now as well so I'll see how that works.

Revision history for this message
Best RaiMan (raimund-hocke) said :
#3

ok, understood.

Since you do not see anything in the logfile, you are using simple print statements for your "logging" and not the features as described here: http://sikulix-2014.readthedocs.io/en/latest/scripting.html#writing-and-redirecting-log-and-debug-messages (which is the kind of logging, as it is used in SikuliX).

the print statement's output in the standard goes to stdout, which in turn in the IDE is per default redirected to the message area.
see: http://sikulix-2014.readthedocs.io/en/latest/faq/010-command-line.html
and the option -c to start the IDE from a commandline and switch off the message box, so all print output goes to stdout (commandline), which in turn can be redirected to a file using > (as you already did for a scriptrun).

you might also use the print statement to directly print to a file:
fLog = open(fnameLog, "w")
print >> fLog, "print test"
fLog.close()

where fnameLog is a valid filename string, that might be formed using os.path.join()
all this is standard Python

Revision history for this message
JayG (jguajardo) said :
#4

Thanks RaiMan, that solved my question.