Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Default logging is not showing any log in Script Console

Jaesang Kim August 13, 2020

Hi all, 

I'm trying to use logging for debugging purposes from ScriptRunner in Confluence. 

In the ScriptConsole, I set the imports and calling log info as below

however it doesn't print out any log. I tried to use log.debug, log.error and so on 

but nothing works.

import com.atlassian.confluence.security.login.LoginManager
import com.atlassian.confluence.user.UserAccessor
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.user.GroupManager
import java.time.LocalDateTime
import java.time.ZoneId

log.info "test message"

I searched then found there is a way to use custom logs but I'm not sure how I can use it.

If you can provide an example of how to use it, it would be very helpful.

Thank you.

Jaesang Kim

 

 

 

 

 

1 answer

0 votes
Will C
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.
August 14, 2020
import org.apache.log4j.Logger
import org.apache.log4j.Level  

def log = Logger.getLogger("com.acme.CreateSubtask")
log.setLevel(Level.DEBUG)  

log.debug "foo bar"

This will be enough to get your logging working. and was taken from this page: https://www.adaptavist.com/doco/display/SFJ/Set%2Blogging%2Bto%2Bhelp%2Bdebug%2Byour%2Bscripts

Jaesang Kim August 14, 2020

Thank you Will C for the comment but it seems not working for me. 

It reads 'No such property : Log for Class : org.apache.log4j.Logger'

I'm trying this from confluence but not from JIRA. The reference you sent me probably work for jira but not in confluence? Thank you again for your help.

Álvaro Honorio
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 30, 2024

Bit late, but in case anything gets here like I did.

Seems like all you need is these lines:

import org.apache.log4j.Level  

log.setLevel(Level.DEBUG)  

log.info("foo bar")

At least for Jira DC v9.4.23 and Scriptrunner v8.30.0

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events