It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Change logfile at runtime without modifying config

Is it possible to change the location of the logfile created by custom scripts? I tried the following code without success:

import org.apache.log4j.Level
import org.apache.log4j.Logger
import org.apache.log4j.SimpleLayout
import org.apache.log4j.FileAppender

log.removeAllAppenders()
log.addAppender(new FileAppender(new SimpleLayout(),"qweasd.log",false))
log.setLevel(Level.DEBUG)
log.error("Test")

I know that the docs mention that you can define a custom FileAppender in something.properties, but I need a way to do this at runtime. If it makes any difference, I tested this snippet using the script console of a local instance of Jira provided by the ScriptRunner sample application. Also, I am aware that it is possible to just create a File and write to that, but I'd very much prefer the comfort of log4j.

1 answer

1 accepted

0 votes
Answer accepted

The code I posted actually works. The issue was that scriptrunner-samples comes with a broken script-root-config which leads to the new log (and I suppose any other file you'd create as well) being created in

scriptrunner-samples\jira\target\container\tomcat8x\cargo-jira-home

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

375 views 1 3
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you