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

Constructor Summary
Log4jKit()
           
 
Method Summary
static void clearMDC()
          This will clear out all the values in the log4j MDC.
static Set<String> getAllLogFiles()
           
static String getLogFileName(String appenderName)
          Returns the full log file name for the given appender.
static void putToMDC(String userName, String requestId, String asessionId, String requestURL)
          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
 

Constructor Detail

Log4jKit

public Log4jKit()
Method Detail

getLogFileName

public static String 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<String> getAllLogFiles()
Returns:
Returns the set of all file appenders configured

putToMDC

public static void putToMDC(String userName,
                            String requestId,
                            String asessionId,
                            String requestURL)
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

putUserToMDC

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

Parameters:
userName - the user name 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-2009 Atlassian. All Rights Reserved.