📄 testndc.java
字号:
/**
* Title : Base Dict Class
* Description : here Description is the function of class, here maybe multirows
* @author <a href="mailto:sunpeng@china.freeborders">kevin</a>
* @Version 1.0
*/
package log4j;
import java.util.logging.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.NDC;
/**
* Class description goes here.
* @version 1.0 2005-10-12
* @author kevin
*/
public class TestNDC
{
static Logger log = Logger.getLogger(TestNDC.class.getName());
public static void main(String[] args) {
log.info("Make sure %x is in your layout pattern!");
// 从客户端获得IP地址的例子
String[] ips = {"192.168.0.10","192.168.0.27"};
for (int i = 0; i<ips.length ; i++) // 模拟一个运行方法
{
// 将IP放进 NDC中
NDC.push(ips[i]);
log.info("A NEW client connected, who's ip should appear in this log message.");
NDC.pop();
//NDC.
}
NDC.remove();
log.info("Finished.");
java.util.logging.Logger javaLog=java.util.logging.Logger.getLogger(TestNDC.class.getName());
//javaLog.setLevel(Level.WARNING );
javaLog.info("++++++++++++");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -