I am current using the following code for my Jira plugin, it is a fragment with a REST endpoint. Here is the code for my REST endpoint below:
import groovy.json.JsonBuilder
import groovy.transform.BaseScript
import com.atlassian.jira.issue.Issue;
import javax.ws.rs.core.Response
import org.apache.log4j.Logger
import groovy.transform.BaseScript
import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import javax.ws.rs.core.MultivaluedMap
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.ScriptRunnerImpl
import com.atlassian.sal.api.ApplicationProperties
import com.atlassian.sal.api.UrlMode
import javax.ws.rs.core.Response
import Helper
@BaseScript CustomEndpointDelegate delegate
def log = Logger.getLogger("atlassian-jira.log")
def bulkSplitterHashMap= Helper.getBulkSplitterHashMap()
int iTracSuperFeatureSplitterIssueTypeID = bulkSplitterHashMap["iTracSuperFeatureSplitterIssueTypeID"] ;
int iTracSuperFeatureSplitterProjectID = bulkSplitterHashMap["iTracSuperFeatureSplitterProjectID"] ;
String iTracSuperFeatureSplitterURL =bulkSplitterHashMap["iTracSuperFeatureSplitterURL"];
callBulkSplitter(httpMethod: "GET", groups: ["jira-users"]) {
MultivaluedMap queryParams, String body ->
def user = ComponentAccessor.jiraAuthenticationContext?.loggedInUser
def issueId = queryParams.getFirst("issueId") as Long
Issue myissue = ComponentAccessor.getIssueManager().getIssueObject(issueId)
def issueKey = myissue.getKey()
def project = myissue.getProject()
def baseUrl = ScriptRunnerImpl.getOsgiService(ApplicationProperties).getBaseUrl(UrlMode.ABSOLUTE)
def iTracSuperFeatureSplitterURL2 = iTracSuperFeatureSplitterURL.replaceAll(":1:", issueKey)
def iTracSuperFeatureSplitterURL3 = iTracSuperFeatureSplitterURL2.replaceAll(":2:", user.getUsername())
def projectID = project.get("id")
int projectIDInt = projectID as int
if (iTracSuperFeatureSplitterProjectID == projectIDInt && iTracSuperFeatureSplitterIssueTypeID == Long.valueOf(myissue.getIssueTypeId())) {
log.warn("The rest endpoint has been executed by the user " +user)
Response.temporaryRedirect(URI.create(iTracSuperFeatureSplitterURL3)).build()
}
}
I am using the following statement to log some values for testing:
def log = Logger.getLogger("atlassian-jira.log")
I am also using this statement for printing the values that I would like to test:
log.warn("The rest endpoint has been executed by the user " +user)
I would like to use a new log called itrac-pulgins and I tried simply replacing the line def log = Logger.getLogger("atlassian-jira.log")
with def log = Logger.getLogger("itrac-plugins.log")
but it didn't work. How can I create a new log called itrac-pulgins where I can print my debugging statements?
You want to create a new log file? For that you would have to update the log4j configuration within your JIRA manually.