To help me to understand how Groovy and Jira libraries are working I try to log some of my values.
On script listeners menu of Script Runner module I can read
"
The following log information was produced by this execution. Use statements like:log.info("...") to record logging information.
No logs were found for this execution.
"
and I can never see any of my log.info("test 1") I write
In "Clones an issue, and links" feature in condition box I would like to log. I woule like to log because the simple line I write seems not working.
The problem is that the default level for the Scriptrunner is Error that is why you can not see messages with the info level. You have several choices
1. Go to Logging and Profiling and set the Info level for com.onresolve package. You will be able to see your logs.
2. You can set the Info level in your script:
import org.apache.log4j.Logger
import org.apache.log4j.Level
log.setLevel(Level.DEBUG)
3. You can define your own logger, which is better, and then set the INFO level for your logger.
import org.apache.log4j.Logger
import org.apache.log4j.Level
def log = Logger.getLogger("com.acme.CreateSubtask")
In this case you should go to the System-> Logging and Profiling and set the INFO level for the com.acme.CreateSubtask logger
4 You can define your own logger and set the INFO level in your script:
import org.apache.log4j.Logger
import org.apache.log4j.Level
def log = Logger.getLogger("com.acme.CreateSubtask")
log.setLevel(Level.DEBUG)
If you need more info on logging, you can read my article about it:
https://community.atlassian.com/t5/Jira-articles/Logging-in-ScriptRunner/ba-p/752758
I've added the following script to a custom listener on issue updated:
package be.fluidda.atlasscripts
import com.atlassian.jira.event.issue.AbstractIssueEventListener
import com.atlassian.jira.event.issue.IssueEvent
import org.apache.log4j.Logger
import static org.apache.log4j.Level.DEBUG
class UpdateField extends AbstractIssueEventListener {
Logger log = Logger.getLogger("be.fluidda.atlasscripts.UpdateField")
@Override
void workflowEvent(IssueEvent event) {
log.setLevel(DEBUG)
log.error "event fired"
}
}
I've tried the 4 options you've sugested, but I keep seeing this message:
No logs were found for this execution.
And when I browse to the logs, nothing is logged there.
Is there somewhere else I need to configure logging?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I had the same problem.
Nothing was logged with "log.info('my log-text')"
For me the simplest solution was to use the command log.warn("here is my logging text")
it works!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Are you using the apache log4j Logger?
import org.apache.log4j.Logger
Regards,
Marcos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.