How to redirect scriptrunner log to another file

Adolfo Casari
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 21, 2017

I am trying to modify log4j.properties so all debugging from scriptrunner addon can be redirected to a separate file , not in atlassian-jira.log.

I have tried this, but no groovy.log is created under log subdirectory of the JIRA HOME directory:

log4j.appender.GroovyLog=com.atlassian.jira.logging.JiraHomeAppender
log4j.appender.GroovyLog.File=groovy.log
log4j.appender.GroovyLog.MaxFileSize=20480KB
log4j.appender.GroovyLog.MaxBackupIndex=5

log4j.appender.GroovyLog.layout=org.apache.log4j.PatternLayout
log4j.appender.GroovyLog.layout.ConversionPattern=%d %t %p [%c{4}] %m%n
log4j.appender.GroovyLog.Threshold=DEBUG

log4j.category.com.onresolve.jira.groovy = DEBUG, console, GroovyLog
log4j.additivity.com.onresolve.jira.groovy = false

 

If instead I replace the first 2 lines for this:

log4j.appender.GroovyLog=org.apache.log4j.RollingFileAppender
log4j.appender.GroovyLog.File=${catalina.home}/logs/groovy.log

It does create groovy.log under the logs subdirectory of the JIRA INSTALLATION directory.

I need groovy.log to be where all application logs are in the log subdirectory of the JIRA HOME directory.

Thanks in advance,

1 answer

1 accepted

0 votes
Answer accepted
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 22, 2017

Hi Adolfo,

I understand you are looking to have scriptrunner create its logs in the $JiraHome/log/ folder instead of the default here in the $JiraInstall/logs/ folder.

The way this could be done would be to create a new variable for the Jira home directory.   By default the setup and installation of Jira doesn't always require Jira installations set this variable manually.  Most times it is not set explicitly, but you can follow How do I set my JIRA home? in order to create an operating system variable called JIRA_HOME. 

The 3rd bullet point on that page has these instructions on how to do this.  Depending on whether this is a Windows vs Linux system the steps on how do to this are slightly different.  But either way you can define this to the specific path of your JIRAHOME path and then at that point you can use the $JIRA_HOME/log path in your script as a means to log files there.

 

Set an environment variable named JIRA_HOME in your operating system whose value is the location of your JIRA home directory. To do this:

  • On Windows, do one of the following:
    • Configure this environment variable through the Windows user interface (typically through 'My Computer' or 'Computer')
    • At the command prompt, enter the following command (with your own JIRA Home path) before running JIRA from the command prompt:
      • set JIRA_HOME=X:\path\to\JIRA\Home
        (warning) Please set your JIRA_HOME  environment variable value using this format, where:
        • X is the drive letter where your JIRA Home Directory is located and
        • no spacing has been added around the equal sign ('=')
    • Specify the command above in a batch file used to start JIRA.
  • On Linux/Solaris, do one of the following:
    • Enter the following command at a shell/console prompt (with your own JIRA Home path) before running JIRA:
      • export JIRA_HOME=/path/to/jira/home
    • Specify the command above in a script used to start JIRA.

 

 

I hope this helps.

Andy

Adolfo Casari
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 23, 2017

Hi Andrew,

Finally I got it wot work. Using JIRA_HOME didn't work for me, but this does:

log4j.appender.GroovyLog.File=${jira.home}/log/groovy.log

I set JIRA_HOME but log4j didn't translate it to the actual directory. On the other hand I noticed jira.home is set within the jira startup script, so I used that instead and work OK.

thanks.

Parikshit Chaudhary July 17, 2023

Hi Team,

I want to create log file on sftp server. how to achieve that?

How to configure log4j.properties file for that?

Thanks in advance!!

Regards,
Parikshit

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 18, 2023

Welcome to the Atlassian Community!

Log4j does not have a way to ftp logs to a remote server.  You will need to script something to do that.

Parikshit Chaudhary July 18, 2023

Hi Nic,

I'm using JSch for communicating to sftp server where I'm providing server Ip address, username, password, and port while I've also used SFTPAppender in my log4j.properties file. 

Still not able to create log file on sftp server.


Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 18, 2023

You will need to go through the SFTPAppender documentation, this is not an Atlassian question.

Parikshit Chaudhary July 18, 2023

Is there any workaround for creating log file on sftp server through scriptrunner for jira data center

Suggest an answer

Log in or Sign up to answer