Script Runner Escalation Service custom logging

I'm looking to migrate functionality from the Jelly Services to using Script Runner Escalation Service.

What I want to do is send an email directly to assignee without necessarily updating the issue 

I've frankensteined together some code borrowed from the "Send a Custom Email" built in script and the source of the Escalation Service built in script itself to use as additional code in the Escalation Service.

I can get the service to do what I want, but I was hoping I could implement some logging within this additional code.  Any suggestion how to instantiate the correct object to be able to write to the log? 

The EscalationService.groovy includes

import org.apache.log4j.Logger
class EscalationService implements CannedScript, PluginJob {
   def log = Logger.getLogger(EscalationService.class)

But since I'm not actually defining a class  I'm not sure how else to get a logger object.

Here is what I have so far:

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.mail.Email
import com.atlassian.mail.MailException
import com.atlassian.mail.MailFactory
import com.atlassian.mail.queue.SingleMailQueueItem
import org.apache.log4j.Logger
def mailServerManager = ComponentAccessor.getMailServerManager();
def mailServer = mailServerManager.getDefaultSMTPMailServer();
if (mailServer && ! MailFactory.isSendingDisabled()) {
	def email = new Email( issue.assignee.emailAddress);
	email.setSubject("[JIRA] Update needed: " + issue.key + " - " + issue.summary)
	email.setBody("Please update" + issue.key + " with the following: \n" +
	"* Current status and actions completed \n" + 
	"* Next Steps \n" +
	"* The names of those responsible for those actions, and the estimated date and time of resolution")
	try {
//		log.debug ("Sending mail to ${email.getTo()}")
//		log.debug ("with body ${email.getBody()}")
		SingleMailQueueItem item = new SingleMailQueueItem(email);
	catch (MailException e) {
//		log.warn ("Error sending email", e)
else {
//	log.warn ("No mail server or sending disabled.")

Perhaps @Jamie Echlin [Adaptavist] has an idea?

Note that I'm quite new at Groovy and even java and I probably have no business fiddling with this... but I figure that's how I'll learn.


1 answer

Hi Peter-Dave Sheenan,

The following code snippet below demonstrates what you will need to be able to write out to the atlassian-jira.log file from within your scripts.


// Import log4j 
import org.apache.log4j.Logger
import org.apache.log4j.Level

// Set the log level to DEBUG

// Some examples of logging statements

// A DEBUG Statement
log.debug("An example Debug statement")

// A INFO Statement"An example Info statement")

// A Warning Statement
log.warn("An example Warming statement")

// A Error Statement
log.error("An example Error statement")


I hope this helps


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Feb 07, 2019 in Marketplace Apps

A Timeless Love Story

It started as any story starts, on a normal, rainy day.   Admin meets App, and her name was Klok2, and like any first relationship we were both trying to make it work but neither one knew what...

478 views 8 28
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you