How to debug/log a rule script

cancel
Showing results for 
Search instead for 
Did you mean: 
jamilnour
Established Member

How to debug/log a rule script

Jump to solution

Hello,

Can you please write a step by step how to debug a Rule repo javascript?

I activated the debug console and changed the needed into the alfresco log4j without success

As for the log I tested with start-pooled-review-workflow.js but I can't find the logger messages

Thanks

Jamil 

1 Solution

Accepted Solutions
mehe
Senior Member II

Re: How to debug/log a rule script

Jump to solution

As a workaround: If you use

logger.system.out("Your message");

you can see your message in tomcat/logs/catalina.out

Or you would have to configure your log4j properties, or use Florian Mauls javascript console add-on GitHub - share-extras/js-console: Administration Console component for Alfresco Share, that enables ... 

View solution in original post

6 Replies
mehe
Senior Member II

Re: How to debug/log a rule script

Jump to solution

As a workaround: If you use

logger.system.out("Your message");

you can see your message in tomcat/logs/catalina.out

Or you would have to configure your log4j properties, or use Florian Mauls javascript console add-on GitHub - share-extras/js-console: Administration Console component for Alfresco Share, that enables ... 

jamilnour
Established Member

Re: How to debug/log a rule script

Jump to solution

For the workaround, do I need to enable any log properties or alfresco client-debug?

jamilnour
Established Member

Re: How to debug/log a rule script

Jump to solution

Yes, client-debug must be enabled. I just tested it

Thank you Martin

mehe
Senior Member II

Re: How to debug/log a rule script

Jump to solution

should work out of the box. The message shows up in catalina.out without any timestamp or so.

So, for debugging, I use a logging function:

function logMe(message) {
    var d = new Date(); //timestamp
    var ds = utils.toISO8601(d) + ""; //use add "" to make sure it's a string
    logger.system.out(ds.replace("T", " ").trim() + " " + script.name + ": " + message);
}‍‍‍‍‍

Code is extremely explicit for better understanding 

script.name is only defined for scripts (rules etc...) not for web scripts. 

mehe
Senior Member II

Re: How to debug/log a rule script

Jump to solution

...didn't know that - Thank you Jamil

jamilnour
Established Member

Re: How to debug/log a rule script

Jump to solution

Okay, I was looking inside alfrescotomcat-stdout.log and not the catalina.out because my alfresco instance is working as a service.

So:

logger.system.out is writing in "alfrescotomcat-stdout.log" if alfresco client-debug is enabled

logger.system.out is writing in "catalina.out" out of the box 

Too helpful because now I can debug my repository javascript Rules without even restart the server

Jamil