當前位置: 首頁>>代碼示例>>Java>>正文


Java NDC.remove方法代碼示例

本文整理匯總了Java中org.apache.log4j.NDC.remove方法的典型用法代碼示例。如果您正苦於以下問題:Java NDC.remove方法的具體用法?Java NDC.remove怎麽用?Java NDC.remove使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.log4j.NDC的用法示例。


在下文中一共展示了NDC.remove方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

import org.apache.log4j.NDC; //導入方法依賴的package包/類
@Override
public final void run()
{
	try
	{
		NDC.inherit(loggingContext);
		CurrentUser.setUserState(callingThreadsAuthentication);
		CurrentInstitution.set(callingThreadsInstitution);
		doRun();
	}
	finally
	{
		CurrentInstitution.remove();
		CurrentUser.setUserState(null);
		NDC.remove();
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:18,代碼來源:AuthenticatedThread.java

示例2: main

import org.apache.log4j.NDC; //導入方法依賴的package包/類
public static void main(String[] argv) throws Exception
{
    clientId = "Listener-" + System.currentTimeMillis();

    NDC.push(clientId);

    Config config = new Config();
    config.setOptions(argv);

    //Connection con = config.createConnection();
    Connection con =
        new AMQConnection("amqp://guest:[email protected]/test?brokerlist='" + config.getHost() + ":" + config.getPort()
                          + "'");

    if (config.getClientId() != null)
    {
        con.setClientID(config.getClientId());
    }

    new Listener(con, config.getAckMode(), config.getSubscriptionId());

    NDC.pop();
    NDC.remove();
}
 
開發者ID:wso2,項目名稱:andes,代碼行數:25,代碼來源:Listener.java

示例3: afterCompletion

import org.apache.log4j.NDC; //導入方法依賴的package包/類
/**
 * Removes the log message from the Log4J NDC after the request is processed.
 */
@Override
public void afterCompletion(WebRequest request, Exception ex) throws Exception {
	NDC.pop();
	if (NDC.getDepth() == 0) {
		NDC.remove();
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:11,代碼來源:Log4jNestedDiagnosticContextInterceptor.java

示例4: afterConcurrentHandlingStarted

import org.apache.log4j.NDC; //導入方法依賴的package包/類
/**
 * Removes the log message from the Log4J NDC when the processing thread is
 * exited after the start of asynchronous request handling.
 */
@Override
public void afterConcurrentHandlingStarted(WebRequest request) {
	NDC.pop();
	if (NDC.getDepth() == 0) {
		NDC.remove();
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:12,代碼來源:Log4jNestedDiagnosticContextInterceptor.java

示例5: afterRequest

import org.apache.log4j.NDC; //導入方法依賴的package包/類
/**
 * Removes the log message from the Log4J NDC after the request is processed
 * and logs the after-request message through Log4J.
 */
@Override
protected void afterRequest(HttpServletRequest request, String message) {
	NDC.pop();
	if (NDC.getDepth() == 0) {
		NDC.remove();
	}
	if (log4jLogger.isDebugEnabled()) {
		log4jLogger.debug(message);
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:15,代碼來源:Log4jNestedDiagnosticContextFilter.java

示例6: cleanDNC

import org.apache.log4j.NDC; //導入方法依賴的package包/類
/**
 * Cleanes DNC context does pop and remove
 */
public static void cleanDNC() {
	NDC.pop();
	NDC.pop();
	NDC.pop();
	NDC.remove();
}
 
開發者ID:ivan-zapreev,項目名稱:x-cure-chat,代碼行數:10,代碼來源:Log4jInit.java

示例7: main

import org.apache.log4j.NDC; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException {
    // Configure the LF5Appender using the DefaultLF5Configurator.  This
    // will add the LF5Appender to the root of the Category tree.
    DefaultLF5Configurator.configure();

    // Add an NDC to demonstrate how NDC information is output.
    NDC.push("#23856");
    // Log some information.
    for (int i = 0; i < 10; i++) {
        logger.debug("Hello, my name is Homer Simpson.");
        logger.info("Mmmmmm .... Chocolate.");
        logger.warn("Mmm...forbidden donut.");
    }
    // Clean up NDC
    NDC.pop();
    NDC.remove();

    NDC.push("Another NDC");
    // Log some information.
    logger.fatal("Hello, my name is Bart Simpson.");
    logger.error("Hi diddly ho good neighbour.");
    // Clean up NDC
    NDC.pop();
    NDC.remove();

    // Call methods on both classes.
    InitUsingDefaultConfigurator.foo();
    InnerInitUsingDefaultConfigurator.foo();

    logger.info("Exiting InitUsingDefaultConfigurator.");

}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:33,代碼來源:InitUsingDefaultConfigurator.java

示例8: foo

import org.apache.log4j.NDC; //導入方法依賴的package包/類
public static void foo() {
    logger.debug("Entered foo in InitUsingDefaultConfigurator class");

    NDC.push("#123456");
    logger.debug("Hello, my name is Marge Simpson.");
    logger.info("D'oh!! A deer! A female deer.");
    // Clean up NDC
    NDC.pop();
    NDC.remove();
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:11,代碼來源:InitUsingDefaultConfigurator.java

示例9: clearLog4JThreadLocals

import org.apache.log4j.NDC; //導入方法依賴的package包/類
/**
 * Clear Log4J threadlocals
 */
protected static void clearLog4JThreadLocals() {
    NDC.remove();
    MDC.clear();
    ThreadLocal tl = getMDCThreadLocal();
    if (tl != null) {
        tl.remove();
    }
}
 
開發者ID:kuali,項目名稱:kc-rice,代碼行數:12,代碼來源:Log4JContextClearingFilter.java

示例10: afterCompletion

import org.apache.log4j.NDC; //導入方法依賴的package包/類
/**
 * Removes the log message from the Log4J NDC after the request is processed.
 */
public void afterCompletion(WebRequest request, Exception ex) throws Exception {
	NDC.pop();
	if (NDC.getDepth() == 0) {
		NDC.remove();
	}
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:10,代碼來源:Log4jNestedDiagnosticContextInterceptor.java

示例11: afterConcurrentHandlingStarted

import org.apache.log4j.NDC; //導入方法依賴的package包/類
/**
 * Removes the log message from the Log4J NDC when the processing thread is
 * exited after the start of asynchronous request handling.
 */
public void afterConcurrentHandlingStarted(WebRequest request) {
	NDC.pop();
	if (NDC.getDepth() == 0) {
		NDC.remove();
	}
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:11,代碼來源:Log4jNestedDiagnosticContextInterceptor.java

示例12: execute

import org.apache.log4j.NDC; //導入方法依賴的package包/類
@Override
protected void execute() {

    if (getPollInterval() < 0) {

        throw new IllegalStateException("Negative poll interval (" + getPollInterval() + ")???");
    }

    NDC.push("[email protected]" + getAddress());

    try {

        while (isEnabled()) {

            currentSignal = getSensorSignal();

            logger.debug("Current signal: " + currentSignal);

            // VT: NOTE: We will notify the listeners even if the
            // signal hasn't changed - their processing logic may
            // suck and just get stuck if they don't get frequent
            // notifications

            broadcast(currentSignal);

            Thread.sleep(pollIntervalMillis);
        }

    } catch (Throwable t) {
        logger.fatal("Unexpected problem, shutting down:", t);
    } finally {
        NDC.pop();
        NDC.remove();
    }
}
 
開發者ID:home-climate-control,項目名稱:dz,代碼行數:36,代碼來源:AbstractAnalogSensor.java

示例13: remove

import org.apache.log4j.NDC; //導入方法依賴的package包/類
/**
 * Remove the diagnostic context for this thread.
 */
public void remove()
{
    NDC.remove();
}
 
開發者ID:Alfresco,項目名稱:alfresco-core,代碼行數:8,代碼來源:Log4JNDC.java

示例14: factor

import org.apache.log4j.NDC; //導入方法依賴的package包/類
public
 int[] factor(int number) throws RemoteException {

   // The client's host is an important source of information.
   try {
     NDC.push(getClientHost());
   }
   catch(java.rmi.server.ServerNotActiveException e) {
     // we are being called from same VM
     NDC.push("localhost");
   }

   // The information contained within the request is another source of
   // distinctive information. It might reveal the users name, date of request,
   // request ID etc. In servlet type environments, much information is
   // contained in cookies.
   NDC.push(String.valueOf(number));    

   logger.info("Beginning to factor.");
   if(number <= 0) {
     throw new IllegalArgumentException(number+" is not a positive integer.");
   }
   else if(number == 1)
      return new int[] {1};
   
   Vector factors = new Vector();
   int n = number;

   for(int i = 2; (i <= n) && (i*i <= number); i++) {
     // It is bad practice to place log requests within tight loops.
     // It is done here to show interleaved log output from
     // different requests. 
     logger.debug("Trying to see if " + i + " is a factor.");

     if((n % i) == 0) {
logger.info("Found factor "+i);
factors.addElement(new Integer(i));
do {
  n /= i;
} while((n % i) == 0);
     }
     // Placing artificial delays in tight-loops will also lead to sub-optimal
     // resuts. :-)
     delay(100);
   }

   if(n != 1) {
     logger.info("Found factor "+n);
     factors.addElement(new Integer(n));
   }
   
   int len = factors.size();
   
   int[] result = new int[len];
   for(int i = 0; i < len; i++) {
     result[i] = ((Integer) factors.elementAt(i)).intValue();
   }

   // Before leaving a thread we call NDC.remove. This deletes the reference
   // to the thread in the internal hash table. Version 0.8.5 introduces a
   // a lazy removal mechanism in case you forget to call remove when
   // exiting a thread. See the java documentation in NDC.remove for further
   // details.
   NDC.remove();
   
   return result;
 }
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:68,代碼來源:NumberCruncherServer.java

示例15: remove

import org.apache.log4j.NDC; //導入方法依賴的package包/類
public static void remove() {
  if (NDCEnabled) {
    NDC.remove();
  }
}
 
開發者ID:hopshadoop,項目名稱:hops-metadata-dal,代碼行數:6,代碼來源:NDCWrapper.java


注:本文中的org.apache.log4j.NDC.remove方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。