Custom logging in Jira
Enable custom logging in Jira with Log4j2
Jira uses Log4j2 as its logging framework to capture and manage system logs. By customizing the log4j2.xml
configuration, you can create targeted logs for specific actions, making monitoring and troubleshooting Jira processes easier.
This guide walks you through adding a custom logger and appender to track CLI actions in a dedicated log file. Follow the steps below to configure your logging setup and generate detailed logs for better visibility into Jira operations.
Configure Log4j2 for custom logging
Add the following logger and appender sections to your log4j2.xml
file to enable custom logging. The file is located by default in: <jira-installation-directory>/atlassian-jira/WEB-INF/classes
.
Add an appender
In the <Appenders>
section, add the following appender:
<JiraHomeAppender name="runcliactions"
fileName="run-cli-actions.log"
filePattern="run-cli-actions.log.%i">
<PatternLayout alwaysWriteExceptions="false">
<Pattern>%d %p: %m%n</Pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggerPolicy size="20480 KB"/>
</Policies>
<DefaultRolloverStrategy fileIndex="min" max="10"/>
</JiraHomeAppender>
Add a logger
In the <Loggers>
section, add the following logger:
<Logger name="org.swift.jira.acli.utilities.CliRunnerHelper.action" level="INFO" additivity="false">
<AppenderRef ref="runcliactions"/>
</Logger>
(Optional) Add an appender reference
To link the appender to the com.atlassian.jira.util.log.LogMarker
logger, add the following reference:
<AppenderRef ref="runcliactions"/>
Example output
After configuring custom logging, Jira generates log entries similar to the following:
2025-01-30 20:39:14,251 INFO:
Issue: AT-5
User: admin(JIRAUSER10000)
Context: validator
Product: jira
Action: --action addComment --issue AT-5 --comment "Comment added via transition to In Progress" --user "admin" --token ***
Result: SUCCESS
Comment with id 10100 added to AT-5.
Message: Comment with id 10100 added to AT-5.