com.atlassian.jira.util.log
Class Log4jKit

java.lang.Object
  extended by com.atlassian.jira.util.log.Log4jKit

public class Log4jKit
extends Object

A class to help with log4j related code

Since:
v4.0

Field Summary
static String MDC_JIRA_ASSESSION_ID
           
static String MDC_JIRA_REQUEST_ID
           
static String MDC_JIRA_REQUEST_IPADDR
           
static String MDC_JIRA_REQUEST_URL
           
static String MDC_JIRA_USERNAME
           
 
Constructor Summary
Log4jKit()
           
 
Method Summary
static void clearMDC()
          This will clear out all the values in the 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 MDC
static void putToMDC(String userName, String requestId, String asessionId, String requestURL, String ipAddr)
          This squirels away request information into the log4j MDC.
static void putUserToMDC(String userName)
          This will add the user name to the log4j MDC
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MDC_JIRA_USERNAME

public static final String MDC_JIRA_USERNAME
See Also:
Constant Field Values

MDC_JIRA_REQUEST_ID

public static final String MDC_JIRA_REQUEST_ID
See Also:
Constant Field Values

MDC_JIRA_ASSESSION_ID

public static final String MDC_JIRA_ASSESSION_ID
See Also:
Constant Field Values

MDC_JIRA_REQUEST_URL

public static final String MDC_JIRA_REQUEST_URL
See Also:
Constant Field Values

MDC_JIRA_REQUEST_IPADDR

public static final String MDC_JIRA_REQUEST_IPADDR
See Also:
Constant Field Values
Constructor Detail

Log4jKit

public Log4jKit()
Method Detail

getLogFileName

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

getAllLogFiles

public static Set<File> getAllLogFiles()
Returns:
Returns the set of all file appenders configured

putToMDC

public static void putToMDC(String userName,
                            String requestId,
                            String asessionId,
                            String requestURL,
                            String ipAddr)
This squirels away request information into the 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

putUserToMDC

public static void putUserToMDC(String userName)
This will add the user name to the log4j MDC

Parameters:
userName - the user name in play

putASessionIdToMDC

public static void putASessionIdToMDC(String atlassianSessionId)
This will set the Atlassian Session Id into the log4j MDC

Parameters:
atlassianSessionId - the session id in play

clearMDC

public static void clearMDC()
This will clear out all the values in the 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.



Copyright © 2002-2012 Atlassian. All Rights Reserved.