b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

log4j appender自定义_log4j routingappender_fileappender log4j(37)

电脑杂谈  发布时间:2017-01-30 04:04:43  来源:网络整理

1 void connect(InetAddress address, int port) {

2if (this.address == null)

3return;

4try {

5cleanUp();

6oos = new ObjectOutputStream(

7new Socket(address, port).getOutputStream());

8} catch (IOException e) {

9if (e instanceof InterruptedIOException) {

10Thread.currentThread().interrupt();

11}

12String msg = "Could not connect to remote log4j server at ["

13+ address.getHostName() + "].";

14if (reconnectionDelay > 0) {

15msg += " We will try again later.";

16fireConnector(); // fire the connector thread

17} else {

18msg += " We are not retrying.";

19errorHandler.error(msg, e, ErrorCode.GENERIC_FAILURE);

20}

21LogLog.error(msg);

22}

23 }

如果创建失败,调用fireConnector()方法,创建一个Connector线程,在每间隔reconnectionDelay(默认值为30000ms,若将其设置为0表示在链接出问题时不创建新的线程检测)的时间里不断重试链接。当链接重新建立后,Connector线程退出并将connector实例置为null以在下一次链接出现问题时创建的Connector线程检测。

1 实例置为null以在下一次链接出现问题时创建的Connector线程检测。

2 void fireConnector() {

3if (connector == null) {

4LogLog.debug("Starting a new connector thread.");

5connector = new Connector();

6connector.setDaemon(true);

7connector.setPriority(Thread.MIN_PRIORITY);

8connector.start();

9}

10 }

11

12 class Connector extends Thread {

13boolean interrupted = false;

14public void run() {

15Socket socket;

16while (!interrupted) {

17try {

18sleep(reconnectionDelay);

19LogLog.debug("Attempting connection to "

20+ address.getHostName());

21socket = new Socket(address, port);

22synchronized (this) {

23oos = new ObjectOutputStream(socket.getOutputStream());

24connector = null;

25LogLog.debug("Connection established. Exiting connector thread.");


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-29497-37.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...