Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Using a Print Statement for debugging

chrizpro March 24, 2019

All in the question, how do I print to console. The log.info "Hello World" didn't work for me. In addition, how do you guys debug Scriptrunner?

 

Thanks

1 answer

1 accepted

0 votes
Answer accepted
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 24, 2019

The bluntest way to do it is System.out.println("your text") but see https://www.adaptavist.com/doco/display/SFJ/Set+logging+to+help+debug+your+scripts for a better way to do it

chrizpro March 24, 2019

I tried that in the service endpoint script and when I checked the logs after the script was fired, I didn't see the message.

chrizpro March 24, 2019

I guess my question should be to you is: can I print out stuff in the service endpoint script? I was unable to print it from the methods listed here:

https://scriptrunner.adaptavist.com/4.3.3/jira/rest-endpoints.html

I put it in the GET method.

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 24, 2019

Then it's not executing the log line for some reason.  Is the script failing or exiting before it gets to the log line?

chrizpro March 24, 2019

Thanks Nic,

I'm not in front of my work computer right now. I just got started working with Scriptrunner last week and this had puzzled, but I do recall the script saying success and printing a JSON when I called the method. I had the print statement before the return statement, so if the return statement executed, then I figured the print statement should have as well.

Here is an image:

Capture.PNG

Just image me System.out.println("Test") right before the return statement.

And that I called

<jira_base_url>/rest/scriptrunner/latest/custom/doSomething

on a button click. That basically what I did, got a success for run, but no log message.

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 26, 2019

Ok, I'm a bit stuck, because I get "Test" dumped into the application log when I use that code.

chrizpro March 26, 2019

Yikes, I'm away from my work computer but application log you're looking at? I put this code in the service endpoint script and did a GET request to make it fire and when I look at the logs, I didn't see anything. Can you please provide me with a screenshot? Maybe I'm looking at the wrong spot.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events