public class

Log4jKit

extends Object
java.lang.Object
   ↳ com.atlassian.jira.util.log.Log4jKit

Class Overview

A class to help with log4j related code

Summary

Constants
String MDC_JIRA_ASSESSION_ID
String MDC_JIRA_REQUEST_ID
String MDC_JIRA_REQUEST_IPADDR
String MDC_JIRA_REQUEST_URL
String MDC_JIRA_USERNAME
Public Constructors
Log4jKit()
Public Methods
static void clearMDC()
This will clear out all the values in the log4j org.apache.log4j.MDC.
static Set<File> getAllLogFiles()
static File getLogFileName(String appenderName)
Returns the full log file name for the given appender.
static void putASessionIdToMDC(String atlassianSessionId)
This will set the Atlassian Session Id into the log4j org.apache.log4j.MDC
static void putToMDC(String userName, String requestId, String asessionId, String requestURL, String ipAddr)
This squirels away request information into the log4j org.apache.log4j.MDC.
static void putUserToMDC(String userName)
This will add the user name to the log4j org.apache.log4j.MDC
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String MDC_JIRA_ASSESSION_ID

Constant Value: "jira.request.assession.id"

public static final String MDC_JIRA_REQUEST_ID

Constant Value: "jira.request.id"

public static final String MDC_JIRA_REQUEST_IPADDR

Constant Value: "jira.request.ipaddr"

public static final String MDC_JIRA_REQUEST_URL

Constant Value: "jira.request.url"

public static final String MDC_JIRA_USERNAME

Constant Value: "jira.username"

Public Constructors

public Log4jKit ()

Public Methods

public static void clearMDC ()

This will clear out all the values in the log4j org.apache.log4j.MDC. This should be done in a finally block perhaps on the outer edge of a request and probably in the start of the request as well.

public static Set<File> getAllLogFiles ()

Returns
  • Returns the set of all file appenders configured

public static File getLogFileName (String appenderName)

Returns the full log file name for the given appender. The appender must be a FileAppender for this to work.

Parameters
appenderName the name of the appender in the log4j configuration
Returns
  • null if one cant be found or the absolute file name of the appender

public static void putASessionIdToMDC (String atlassianSessionId)

This will set the Atlassian Session Id into the log4j org.apache.log4j.MDC

Parameters
atlassianSessionId the session id in play

public static void putToMDC (String userName, String requestId, String asessionId, String requestURL, String ipAddr)

This squirels away request information into the log4j org.apache.log4j.MDC.

Parameters
userName the user name in play
requestId the request id
asessionId the Atlassian Session ID (hash of session id)
requestURL the request URL
ipAddr the ipaddress of the clint making the request

public static void putUserToMDC (String userName)

This will add the user name to the log4j org.apache.log4j.MDC

Parameters
userName the user name in play