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


Java NDC.pop方法代碼示例

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


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

示例1: bubbleSort

import org.apache.log4j.NDC; //導入方法依賴的package包/類
void bubbleSort() {
   LOG.info( "Entered the sort method.");

   for(int i = intArray.length -1; i >= 0  ; i--) {
     NDC.push("i=" + i);
     OUTER.debug("in outer loop.");
     for(int j = 0; j < i; j++) {
NDC.push("j=" + j);
// It is poor practice to ship code with log staments in tight loops.
// We do it anyway in this example.
INNER.debug( "in inner loop.");
        if(intArray[j] > intArray[j+1])
   swap(j, j+1);
NDC.pop();
     }
     NDC.pop();
   }
 }
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:19,代碼來源:SortAlgo.java

示例2: test4

import org.apache.log4j.NDC; //導入方法依賴的package包/類
/**
 *  The pattern on the server side: %5p %x %X{key1}%X{key4} [%t] %c{1} - %m%n 
 *  meaning that we are testing NDC, MDC and localization functionality across 
 *  the wire.  
*/
public void test4() throws Exception {
  socketAppender = new SocketAppender("localhost", PORT);
  socketAppender.setLocationInfo(true);
  rootLogger.addAppender(socketAppender);

  NDC.push("some");
  common("T4", "key4", "MDC-TEST4");
  NDC.pop();
  delay(1);
  //
  //  These tests check MDC operation which
  //    requires JDK 1.2 or later
  if(!System.getProperty("java.version").startsWith("1.1.")) {
  
      ControlFilter cf = new ControlFilter(new String[]{PAT4, EXCEPTION1, 
				           EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5});
      Transformer.transform(
        TEMP, FILTERED,
        new Filter[] { cf, new LineNumberFilter(), 
            new JunitTestRunnerFilter(),
            new SunReflectFilter() });

      assertTrue(Compare.compare(FILTERED, "witness/socketServer.4"));
  }
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:31,代碼來源:SocketServerTestCase.java

示例3: test8

import org.apache.log4j.NDC; //導入方法依賴的package包/類
/**
 * The pattern on the server side: %5p %x %X{hostID}${key7} [%t] %c{1} - %m%n 
 *
 * This test checks whether server side MDC works.
 */
public void test8() throws Exception {
  socketAppender = new SocketAppender("localhost", PORT);
  socketAppender.setLocationInfo(true);
  rootLogger.addAppender(socketAppender);

  NDC.push("some8");
  common("T8", "key8", "MDC-TEST8");
  NDC.pop();
  delay(2);
  //
  //  These tests check MDC operation which
  //    requires JDK 1.2 or later
  if(!System.getProperty("java.version").startsWith("1.1.")) {
      ControlFilter cf = new ControlFilter(new String[]{PAT8, EXCEPTION1, 
				           EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5});
  
      Transformer.transform(
        TEMP, FILTERED,
        new Filter[] { cf, new LineNumberFilter(), 
            new JunitTestRunnerFilter(),
            new SunReflectFilter() });
      assertTrue(Compare.compare(FILTERED, "witness/socketServer.8"));
  }
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:30,代碼來源:SocketServerTestCase.java

示例4: service

import org.apache.log4j.NDC; //導入方法依賴的package包/類
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
    count_++;
    String ndcName = getClass().getName();
    ndcName = ndcName.substring(ndcName.lastIndexOf('.')+1);
    NDC.push(ndcName);
    NDC.push("call-" + count_);
    logger_.info("begin onService");
    try
    {
        onService(req, resp);
    }
    catch (Exception exc)
    {
        lastException = exc;
        resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
    finally
    {
        logger_.info("end onService");
        NDC.pop();
        NDC.pop();
    }
}
 
開發者ID:jbufu,項目名稱:openid4java,代碼行數:25,代碼來源:HttpServletSupport.java

示例5: run

import org.apache.log4j.NDC; //導入方法依賴的package包/類
@Override
public void run() {
    try {
        final InetAddress remoteAddress = socket.getInetAddress();
        NDC.push("DaemonWorker(" + socket.getRemoteSocketAddress() + ")");
        try {
            internalRun();
        } finally {
            NDC.pop();
        }
    } catch (RuntimeException e) {
        if (e.getCause() instanceof SocketException) {
            log.warn("worker exception", e);
        } else if (e instanceof IllegalArgumentException) {
            log.warn("worker exception", e);
        } else {
            log.error("worker exception", e);
        }
        throw e;
    }
}
 
開發者ID:indeedeng,項目名稱:imhotep,代碼行數:22,代碼來源:ImhotepDaemon.java

示例6: networkFault

import org.apache.log4j.NDC; //導入方法依賴的package包/類
@Override
public void networkFault(OneWireNetworkEvent e, String message) {
    
    NDC.push("networkFault");
    
    try {
        
        // This is an event pertinent to everyone
        
        consume(new DataSample<Double>(
                System.currentTimeMillis(), type + getAddress(), type + getAddress(),
                null, new OneWireIOException(message)));

    } finally {
        NDC.pop();
    }
}
 
開發者ID:home-climate-control,項目名稱:dz,代碼行數:18,代碼來源:OwapiDeviceFactory.java

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: test5

import org.apache.log4j.NDC; //導入方法依賴的package包/類
/**
 * The pattern on the server side: %5p %x %X{key1}%X{key5} [%t] %c{1} - %m%n 
 *
 * The test case uses wraps an AsyncAppender around the
 * SocketAppender. This tests was written specifically for bug
 * report #9155.

 * Prior to the bug fix the output on the server did not contain the
 * MDC-TEST5 string because the MDC clone operation (in getMDCCopy
 * method) operation is performed twice, once from the main thread
 * which is correct, and a second time from the AsyncAppender's
 * dispatch thread which is incrorrect.

 */
public void test5() throws Exception {
  socketAppender = new SocketAppender("localhost", PORT);
  socketAppender.setLocationInfo(true);
  AsyncAppender asyncAppender = new AsyncAppender();
  asyncAppender.setLocationInfo(true);
  asyncAppender.addAppender(socketAppender);
  rootLogger.addAppender(asyncAppender);

  NDC.push("some5");
  common("T5", "key5", "MDC-TEST5");
  NDC.pop();
  delay(2);
  //
  //  These tests check MDC operation which
  //    requires JDK 1.2 or later
  if(!System.getProperty("java.version").startsWith("1.1.")) {
      ControlFilter cf = new ControlFilter(new String[]{PAT5, EXCEPTION1, 
				           EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5});
  
      Transformer.transform(
        TEMP, FILTERED,
        new Filter[] { cf, new LineNumberFilter(), 
            new JunitTestRunnerFilter(),
            new SunReflectFilter() });

      assertTrue(Compare.compare(FILTERED, "witness/socketServer.5"));
  }
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:43,代碼來源:SocketServerTestCase.java

示例14: test6

import org.apache.log4j.NDC; //導入方法依賴的package包/類
/**
 * The pattern on the server side: %5p %x %X{hostID}${key6} [%t] %c{1} - %m%n 
 *
 * This test checks whether client-side MDC overrides the server side.
 * It uses an AsyncAppender encapsulating a SocketAppender
 */
public void test6() throws Exception {
  socketAppender = new SocketAppender("localhost", PORT);
  socketAppender.setLocationInfo(true);
  AsyncAppender asyncAppender = new AsyncAppender();
  asyncAppender.setLocationInfo(true);
  asyncAppender.addAppender(socketAppender);
  rootLogger.addAppender(asyncAppender);

  NDC.push("some6");
  MDC.put("hostID", "client-test6");
  common("T6", "key6", "MDC-TEST6");
  NDC.pop();
  MDC.remove("hostID");
  delay(2);
  //
  //  These tests check MDC operation which
  //    requires JDK 1.2 or later
  if(!System.getProperty("java.version").startsWith("1.1.")) {
      ControlFilter cf = new ControlFilter(new String[]{PAT6, EXCEPTION1, 
				           EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5});
  
      Transformer.transform(
        TEMP, FILTERED,
        new Filter[] { cf, new LineNumberFilter(), 
            new JunitTestRunnerFilter(),
            new SunReflectFilter() });

      assertTrue(Compare.compare(FILTERED, "witness/socketServer.6"));
  }
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:37,代碼來源:SocketServerTestCase.java

示例15: test7

import org.apache.log4j.NDC; //導入方法依賴的package包/類
/**
 * The pattern on the server side: %5p %x %X{hostID}${key7} [%t] %c{1} - %m%n 
 *
 * This test checks whether client-side MDC overrides the server side.
 */
public void test7() throws Exception {
  socketAppender = new SocketAppender("localhost", PORT);
  socketAppender.setLocationInfo(true);
  rootLogger.addAppender(socketAppender);

  NDC.push("some7");
  MDC.put("hostID", "client-test7");
  common("T7", "key7", "MDC-TEST7");
  NDC.pop();
  MDC.remove("hostID"); 
  delay(2);
  //
  //  These tests check MDC operation which
  //    requires JDK 1.2 or later
  if(!System.getProperty("java.version").startsWith("1.1.")) {
      ControlFilter cf = new ControlFilter(new String[]{PAT7, EXCEPTION1, 
				           EXCEPTION2, EXCEPTION3, EXCEPTION4, EXCEPTION5});
  
      Transformer.transform(
        TEMP, FILTERED,
        new Filter[] { cf, new LineNumberFilter(), 
            new JunitTestRunnerFilter(),
            new SunReflectFilter() });
      assertTrue(Compare.compare(FILTERED, "witness/socketServer.7"));
  }
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:32,代碼來源:SocketServerTestCase.java


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