Forums

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

Not seeing logging from behavior scripts

Edward Greathouse September 11, 2018

Hi,

I set up a "Behavior" using Scriptrunner. Here is my script:

import org.apache.log4j.Level
import org.apache.log4j.Logger

def myLog = Logger.getLogger("com.onresolve.jira.groovy")
myLog.setLevel(Level.DEBUG)

def cfOrigin = getFieldById("customfield_10906")

myLog.debug("cfOrigin: " + cfOrigin.getValue())

if (cfOrigin.getValue() == "Implementation") {
myLog.debug(" Not Hiding! ")
getFieldById(getFieldChanged()).setHidden(false)
}
else {
myLog.debug(" Hiding! ")
getFieldById(getFieldChanged()).setHidden(true)
}



Unfortunately, I'm not able to find "cfOrigin: " in any logs (I looked at C:\Program Files\Atlassian\Application Data\JIRA\log). Where else should I be looking for these messages?

Also, nothing happens with this behavior.

 

1 answer

1 vote
manognavm September 11, 2018

 

Please Try

log.info "cfOrigin: "cfOrigin.getValue()

You will probably also need to enable logging for Behaviours to ensure that the message shows up.

Once you've done those things, try triggering the behaviour again and then check your atlassian-jira.log file to see if the message has shown up.

 

Are you trying to get the Id of the field ,you attached the behavior to ?

getFieldById(getFieldChanged())
manognavm September 11, 2018
Can you try attaching behavior to your customfield_10906 , replace fieldId to be hidden in formField in the below code 

def cfOrigin = getFieldById(getFieldChanged())
def cfValue = cfOrigin.value

log.info "cfOrigin: " + cfValue

def hField = getFieldById("formField")

if (cfValue == "Implementation") {

hField.setHidden(true)

}
else {

hfield.setHidden(false)

 

Edward Greathouse September 12, 2018

Hi Manu,

I'm still not able to see any logs. I have enabled logging for Behaviors (for some reason, it's not letting attach a screenshot of that), but I have added the `log.info` statement to the script. When I checked the above link "Your atlassian-jira.log file", I did not have a JIRA installation Directory at "c:\WINDOWS\system32". I am able to find a file called `atlassian-jira.log`, but it is located at "C:\Program Files\Atlassian\Application Data\JIRA\log".

 

The purpose of the script was to hide a custom field based on the value of another custom script. I was able to get it to work by changing the custom field that the behavior is happening on. However, I'm still not seeing anything in the logs and I need to debug other behavior scripts I have written.

Here is my updated script:


import org.apache.log4j.Level
import org.apache.log4j.Logger

def myLog = Logger.getLogger("com.onresolve.jira.groovy")
myLog.setLevel(Level.DEBUG)

def cfSendEmail = getFieldById("customfield_11408")

myLog.debug("cfSendEmail: " + cfSendEmail.getValue())
log.info "cfSendEmail: " + cfSendEmail.getValue()

if (getFieldById(getFieldChanged()).getValue() == "Implementation") {
myLog.debug(" Not Hiding! ")
cfSendEmail.setHidden(false)
}
else {
myLog.debug(" Hiding! ")
cfSendEmail.setHidden(true)
}



Any help would be greatly appreciated!

manognavm September 17, 2018

Alright, here is what I would do,

 

search for "Logging and Profiling" and go for Default logger and

set    Package name : com.onresolve.jira.groovy

         Logging Level : DEBUG 

 

and Check for Atlassian-Jira.log by navigating to 

Built-in script --> View Server log files

 

if you Run it, you should be able to see it something like this

/rest/scriptrunner/behaviours/latest/runvalidator.json [c.onresolve.jira.groovy]cfSendEmail: blahblahblah..
manognavm September 17, 2018

FYI.. Logging and Profiling is in Systems(Global Administrator)

and

Built-in script is in Add-ons.

 

Please let me know if you have any other questions. 

Suggest an answer

Log in or Sign up to answer