How do I get logging to work

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Trevor Hughes
Junior Coder
Posts: 25
Joined: Sun Dec 15, 2013 9:27 pm

How do I get logging to work

Post by Trevor Hughes » Wed Feb 22, 2017 8:42 pm

Hello

I want to enable logging for my scripts, however I cannot figure out how to do this.

I've gone to the Logging tab and specified a log file eg.
C:\Logging\ScriptName.txt

However this does not appear to do anything. I cannot find any info on how to do this. If some-one could provide to guidance I would appreciate it.

Kind regards
Trevor

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: How do I get logging to work

Post by mightycpa » Thu Feb 23, 2017 2:30 am

Did you notice this little snippet at the top?
Note: Logging has no effect when scripts are run within the debugger.
I'm thinking this means you have to compile and run.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: How do I get logging to work

Post by Marcus Tettmar » Thu Feb 23, 2017 1:16 pm

You certainly do not need to compile it. This has nothing to do with compiling (in fact if you compile you need to either pass a log file to the .exe when you run it or build that in with the compile settings).

Believe it or not it means precisely what it says - logging has no effect when running in the debugger. If that makes no sense we better talk about what the debugger is. You are using the debugger when you run code while you are in the editor.

** if you can see your code you are in the debugger **

If you CLOSE the script editor and then run the macro the logging will take effect.

So the logging works when:

- You run the macro from the main window (where you see a list of macros)
- When a schedule runs the macro
- When a hotkey runs the macro
- When you run the macro from a shortcut
- When you run the macro from the system tray Quick Launch option.

So basically once you have defined logging it will ALWAYS work UNLESS you open up the macro in the editor and run from within there. If you are editing you are debugging when you run. Logging has no effect in this instance.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: How do I get logging to work

Post by mightycpa » Thu Feb 23, 2017 3:59 pm

Not so fast, Marcus! I don't think that instruction is quite as clear as you think.

In Scripting Windows for Beginners, under Using Macro Scheduler, there's this:
Select File/New Macro from the main menu or click the New toolbar button. This will open an empty new macro and put you directly in the Script Editor.
Clicking the link will reveal the Script Editor.

Image

Further, if you search for Debugger in the Help Index, you'll see this:

Image

Clearly, the debugger is a feature of the Script Editor, accessible only from within the menu of the Script Editor. Besides, what sense would it make to have a debugger within the Debugger?

Even your post switches to the correct term in order to clarify your meaning (emphasis added by me):
Believe it or not it means precisely what it says - logging has no effect when running in the debugger. If that makes no sense we better talk about what the debugger is. You are using the debugger when you run code while you are in the editor.

** if you can see your code you are in the debugger **

If you CLOSE the script editor and then run the macro the logging will take effect.
What my limited testing has revealed is that it works exactly as you described. When you're debugging, the logging doesn't work, and when you're running the script from within the Script Editor, the logging doesn't work there either. It's not until you close the script and run it outside of the Script Editor that the logging begins to work.

I would respectfully suggest that your disclaimer description really means that logging has no effect when scripts are run from within the Script Editor, whether using the Debugger or not.

Lastly, I'd encourage you to update the contents of the Help file for the index entry Editor.

The good news is that this is exactly why I keep returning to these forums...for clarity! :D

Thanks for everything!
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: How do I get logging to work

Post by Marcus Tettmar » Thu Feb 23, 2017 4:05 pm

The Script Editor = The Debugger. When you run a script in the script editor you see the watch list. Always.

I could add "the script editor is the debugger" in the help file. I'll do that. How much do you want to bet people will read it?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: How do I get logging to work

Post by mightycpa » Thu Feb 23, 2017 4:17 pm

I only know of one guy who's read it so far. :)
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

Trevor Hughes
Junior Coder
Posts: 25
Joined: Sun Dec 15, 2013 9:27 pm

Re: How do I get logging to work

Post by Trevor Hughes » Thu Feb 23, 2017 8:12 pm

Thank you for the comments on this question.

For clarity from my perspective, for a number of reasons I always run scripts with the Script Editor open. This is because I am using Macro Scheduler to test our applications which can be very flakey.

If I want to use logging I would need to compile the script(?) using a copy of Macro Scheduler Pro(?) which I have, into an EXE and then run the EXE. I assume that doing this will allow the logging to work?

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: How do I get logging to work

Post by mightycpa » Thu Feb 23, 2017 8:26 pm

No, you don't have to compile, just run it from this view:

Image
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: How do I get logging to work

Post by Dorian (MJT support) » Fri Mar 03, 2017 1:35 am

mightycpa wrote:No, you don't have to compile, just run it from this view:

Image
Yes, MightCPA is correct. Thank you for clarifying. :D
Yes, we have a Custom Scripting Service. Message me or go here

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Trick to getting logging working in compiled script?

Post by mightycpa » Sat Apr 01, 2017 1:20 am

My compiled script won't produce a log.

I've done this:

Image

and this:

Image

The only unusual thing is that the path for my log does not exist on the machine where I'm compiling. It exists on the machine I'm running the compiled version on. That shouldn't make a difference, should it?

What else do I need to do? The log simply does not get produced, and I need it.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: How do I get logging to work

Post by JRL » Sat Apr 01, 2017 3:52 am

Once a script is compiled, the Macro Scheduler menu no longer has any impact on the stand alone executable file or its processing. You will need to compile with the "Disable logging" checkbox unchecked. To log an executable you need to run the executable from some sort of command line. The command line will say something like:

MyScript.exe /logfile=logfile.txt

Typically I will create a shortcut to run the command line. You can also run one from a DOS shell or from another Macro Scheduler script.

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: How do I get logging to work

Post by mightycpa » Sat Apr 01, 2017 4:47 am

Hi JRL,

I just found this thread:

viewtopic.php?f=2&t=9188&p=40199&hilit= ... exe#p40199

and it basically showed me what you just said, and yes, it works.

In that same thread, you wrote about _WRITE_LOG_FILE=1 or 0 where 1 means write and 0 means don't. That didn't work for me. I mostly don't want to log, I'm have a very specific issue and I just wanted to log a few lines, but I can't see how to do it. Any thoughts on that? Example:

Code: Select all

Let>_WRITE_LOG_FILE=1
//MessageModal>vfilectr is %v_file_ctr% and vfilelistcount is %v_file_list_COUNT%
Until>v_file_ctr>%v_file_list_COUNT%
Let>_WRITE_LOG_FILE=0
It just keeps on logging after that.

What I did see, which was an unexpected treat, was that if I had a line like this:

Code: Select all

//MessageModal> My var value is %var_value%
I could see the values in the commented line, like so:
3/31/2017 23:41:14:686 - START: 215: //MessageModal>vfilectr is 15 and vfilelistcount is 106
3/31/2017 23:41:14:686 - END: 215: //MessageModal>vfilectr is 15 and vfilelistcount is 106
Too cool for school!

If I could turn most of the logging off, that would be great.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: How do I get logging to work

Post by mightycpa » Sat Apr 01, 2017 5:42 am

Hi JRL,

I got it! Put a _WRITE_LOG_FILE=0 up at the top of the script..... DUH! :)

OK, thanks for all your assistance.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts