Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,457,046
Community Members
 
Community Events
176
Community Groups

JiraHomeAppender/FileAppender not working as expected in Jira 9.5

Edited
  • JiraHomeAppender - throws an IllegalAccessError when used in Jira 9.5.

Code Snippet:

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import com.atlassian.jira.logging.JiraHomeAppender;

......

private final Logger rootLogger = Logger.getRootLogger();

.....

private void initLogger() {
   JiraHomeAppender jiraHomeAppender = new JiraHomeAppender();
   jiraHomeAppender.setName(Constants.LOGGING_NAME);
   jiraHomeAppender.setFile("test.log");
   jiraHomeAppender.setLayout(new PatternLayout("%d %-5p [%c{1}] %m%n"));
   jiraHomeAppender.setThreshold(Level.INFO);
   jiraHomeAppender.setAppend(true);
   jiraHomeAppender.activateOptions();

   rootLogger.addAppender(jiraHomeAppender);
   rootLogger.getLoggerRepository()
             .getLogger(Constants.LOGGING_NAME).setLevel(Level.INFO);
}

Error:

JiraHomeAppender error.png

 

  • FileAppender/RollingFileAppender - I used this as an alternative fix for the JiraHomeAppender issue. The error doesn't occur, and custom log file has been created, but the problem is that there are no logs being printed in the file in Jira 9.5, but working as expected in lower versions. Is there something that I need to add to this configuration?

Code Snippet:

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.FileAppender;
........

private final Logger rootLogger = Logger.getRootLogger();
........

private void initLogger() { 
    FileAppender fileAppender = new FileAppender();
    fileAppender.setName(Constants.LOGGING_NAME);
    fileAppender.setFile("jira/home/test.log");
    fileAppender.setLayout(new PatternLayout("%d %-5p [%c\{1}] %m%n"));
    fileAppender.setThreshold(Level.INFO);
    fileAppender.activateOptions(); 
 
    rootLogger.addAppender(fileAppender);
    rootLogger.getLoggerRepository()
              .getLogger(Constants.LOGGING_NAME).setLevel(Level.INFO);
}

 

Do you have any suggestions to resolve this issue?

 

Thank you.

1 comment

Tuncay Senturk Community Leader Dec 17, 2022

Hi @Trishia Mae Gumboc 

Welcome to the Community!

Jira 9.5 is the log4j update ( >=2.17.2). Here you can find information about the update.

This might be helpful for your problem. You can also check this article.

I hope you find them helpful.

Hi @Tuncay Senturk

I dont know if i missed something from the details but i haven't seen any details whether if it is backwards compatible with older jira versions? I have already a working fix with jira 9.5 but unfortunately it isn't working with older versions.

Thanks,
fritz

Tuncay Senturk Community Leader Dec 21, 2022

No, it won't be backward compatible. You need to have separate binaries for each (one for < Jira 9.5 and the other for >= Jira 9.5)

If you want to have one binary to have backward compatibility, you must implement a bridge API. Have a look at this post. It may shed a light.

Comment

Log in or Sign up to comment