亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? socketappender.java

?? apache的log4j源碼
?? JAVA
字號:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at *  *      http://www.apache.org/licenses/LICENSE-2.0 *  * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */// Contributors: Dan MacDonald <dan@redknee.com>package org.apache.log4j.net;import java.io.IOException;import java.io.ObjectOutputStream;import java.net.InetAddress;import java.net.Socket;import org.apache.log4j.AppenderSkeleton;import org.apache.log4j.helpers.LogLog;import org.apache.log4j.spi.ErrorCode;import org.apache.log4j.spi.LoggingEvent;/**    Sends {@link LoggingEvent} objects to a remote a log server,    usually a {@link SocketNode}.    <p>The SocketAppender has the following properties:    <ul>      <p><li>If sent to a {@link SocketNode}, remote logging is      non-intrusive as far as the log event is concerned. In other      words, the event will be logged with the same time stamp, {@link      org.apache.log4j.NDC}, location info as if it were logged locally by      the client.      <p><li>SocketAppenders do not use a layout. They ship a      serialized {@link LoggingEvent} object to the server side.      <p><li>Remote logging uses the TCP protocol. Consequently, if      the server is reachable, then log events will eventually arrive      at the server.      <p><li>If the remote server is down, the logging requests are      simply dropped. However, if and when the server comes back up,      then event transmission is resumed transparently. This      transparent reconneciton is performed by a <em>connector</em>      thread which periodically attempts to connect to the server.      <p><li>Logging events are automatically <em>buffered</em> by the      native TCP implementation. This means that if the link to server      is slow but still faster than the rate of (log) event production      by the client, the client will not be affected by the slow      network connection. However, if the network connection is slower      then the rate of event production, then the client can only      progress at the network rate. In particular, if the network link      to the the server is down, the client will be blocked.      <p>On the other hand, if the network link is up, but the server      is down, the client will not be blocked when making log requests      but the log events will be lost due to server unavailability.      <p><li>Even if a <code>SocketAppender</code> is no longer      attached to any category, it will not be garbage collected in      the presence of a connector thread. A connector thread exists      only if the connection to the server is down. To avoid this      garbage collection problem, you should {@link #close} the the      <code>SocketAppender</code> explicitly. See also next item.      <p>Long lived applications which create/destroy many      <code>SocketAppender</code> instances should be aware of this      garbage collection problem. Most other applications can safely      ignore it.      <p><li>If the JVM hosting the <code>SocketAppender</code> exits      before the <code>SocketAppender</code> is closed either      explicitly or subsequent to garbage collection, then there might      be untransmitted data in the pipe which might be lost. This is a      common problem on Windows based systems.      <p>To avoid lost data, it is usually sufficient to {@link      #close} the <code>SocketAppender</code> either explicitly or by      calling the {@link org.apache.log4j.LogManager#shutdown} method      before exiting the application.     </ul>    @author  Ceki G&uuml;lc&uuml;    @since 0.8.4 */public class SocketAppender extends AppenderSkeleton {  /**     The default port number of remote logging server (4560).     @since 1.2.15  */  static public final int DEFAULT_PORT                 = 4560;  /**     The default reconnection delay (30000 milliseconds or 30 seconds).  */  static final int DEFAULT_RECONNECTION_DELAY   = 30000;  /**     We remember host name as String in addition to the resolved     InetAddress so that it can be returned via getOption().  */  String remoteHost;  InetAddress address;  int port = DEFAULT_PORT;  ObjectOutputStream oos;  int reconnectionDelay = DEFAULT_RECONNECTION_DELAY;  boolean locationInfo = false;  private String application;  private Connector connector;  int counter = 0;  // reset the ObjectOutputStream every 70 calls  //private static final int RESET_FREQUENCY = 70;  private static final int RESET_FREQUENCY = 1;  public SocketAppender() {  }  /**     Connects to remote server at <code>address</code> and <code>port</code>.  */  public SocketAppender(InetAddress address, int port) {    this.address = address;    this.remoteHost = address.getHostName();    this.port = port;    connect(address, port);  }  /**     Connects to remote server at <code>host</code> and <code>port</code>.  */  public SocketAppender(String host, int port) {    this.port = port;    this.address = getAddressByName(host);    this.remoteHost = host;    connect(address, port);  }  /**     Connect to the specified <b>RemoteHost</b> and <b>Port</b>.  */  public void activateOptions() {    connect(address, port);  }  /**   * Close this appender.     *   * <p>This will mark the appender as closed and call then {@link   * #cleanUp} method.   * */  synchronized public void close() {    if(closed)      return;    this.closed = true;    cleanUp();  }  /**   * Drop the connection to the remote host and release the underlying   * connector thread if it has been created    * */  public void cleanUp() {    if(oos != null) {      try {	oos.close();      } catch(IOException e) {	LogLog.error("Could not close oos.", e);      }      oos = null;    }    if(connector != null) {      //LogLog.debug("Interrupting the connector.");      connector.interrupted = true;      connector = null;  // allow gc    }  }  void connect(InetAddress address, int port) {    if(this.address == null)      return;    try {      // First, close the previous connection if any.      cleanUp();      oos = new ObjectOutputStream(new Socket(address, port).getOutputStream());    } catch(IOException e) {      String msg = "Could not connect to remote log4j server at ["	+address.getHostName()+"].";      if(reconnectionDelay > 0) {        msg += " We will try again later.";	fireConnector(); // fire the connector thread      } else {          msg += " We are not retrying.";          errorHandler.error(msg, e, ErrorCode.GENERIC_FAILURE);      }       LogLog.error(msg);    }  }  public void append(LoggingEvent event) {    if(event == null)      return;    if(address==null) {      errorHandler.error("No remote host is set for SocketAppender named \""+			this.name+"\".");      return;    }    if(oos != null) {      try {    	 	if(locationInfo) {	   event.getLocationInformation();	}    if (application != null) {        event.setProperty("application", application);    }	oos.writeObject(event);	//LogLog.debug("=========Flushing.");	oos.flush();	if(++counter >= RESET_FREQUENCY) {	  counter = 0;	  // Failing to reset the object output stream every now and	  // then creates a serious memory leak.	  //System.err.println("Doing oos.reset()");	  oos.reset();	}      } catch(IOException e) {	oos = null;	LogLog.warn("Detected problem with connection: "+e);	if(reconnectionDelay > 0) {	  fireConnector();	} else {	    errorHandler.error("Detected problem with connection, not reconnecting.", e,	               ErrorCode.GENERIC_FAILURE);	}      }    }  }  void fireConnector() {    if(connector == null) {      LogLog.debug("Starting a new connector thread.");      connector = new Connector();      connector.setDaemon(true);      connector.setPriority(Thread.MIN_PRIORITY);      connector.start();    }  }  static  InetAddress getAddressByName(String host) {    try {      return InetAddress.getByName(host);    } catch(Exception e) {      LogLog.error("Could not find address of ["+host+"].", e);      return null;    }  }  /**   * The SocketAppender does not use a layout. Hence, this method   * returns <code>false</code>.     * */  public boolean requiresLayout() {    return false;  }  /**   * The <b>RemoteHost</b> option takes a string value which should be   * the host name of the server where a {@link SocketNode} is   * running.   * */  public void setRemoteHost(String host) {    address = getAddressByName(host);    remoteHost = host;  }  /**     Returns value of the <b>RemoteHost</b> option.   */  public String getRemoteHost() {    return remoteHost;  }  /**     The <b>Port</b> option takes a positive integer representing     the port where the server is waiting for connections.   */  public void setPort(int port) {    this.port = port;  }  /**     Returns value of the <b>Port</b> option.   */  public int getPort() {    return port;  }  /**     The <b>LocationInfo</b> option takes a boolean value. If true,     the information sent to the remote host will include location     information. By default no location information is sent to the server.   */  public void setLocationInfo(boolean locationInfo) {    this.locationInfo = locationInfo;  }  /**     Returns value of the <b>LocationInfo</b> option.   */  public boolean getLocationInfo() {    return locationInfo;  }  /**   * The <b>App</b> option takes a string value which should be the name of the    * application getting logged.   * If property was already set (via system property), don't set here.   */  public void setApplication(String lapp) {    this.application = lapp;  }  /**   *  Returns value of the <b>Application</b> option.   */  public String getApplication() {    return application;  }  /**     The <b>ReconnectionDelay</b> option takes a positive integer     representing the number of milliseconds to wait between each     failed connection attempt to the server. The default value of     this option is 30000 which corresponds to 30 seconds.     <p>Setting this option to zero turns off reconnection     capability.   */  public void setReconnectionDelay(int delay) {    this.reconnectionDelay = delay;  }  /**     Returns value of the <b>ReconnectionDelay</b> option.   */  public int getReconnectionDelay() {    return reconnectionDelay;  }  /**     The Connector will reconnect when the server becomes available     again.  It does this by attempting to open a new connection every     <code>reconnectionDelay</code> milliseconds.     <p>It stops trying whenever a connection is established. It will     restart to try reconnect to the server when previpously open     connection is droppped.     @author  Ceki G&uuml;lc&uuml;     @since 0.8.4  */  class Connector extends Thread {    boolean interrupted = false;    public    void run() {      Socket socket;      while(!interrupted) {	try {	  sleep(reconnectionDelay);	  LogLog.debug("Attempting connection to "+address.getHostName());	  socket = new Socket(address, port);	  synchronized(this) {	    oos = new ObjectOutputStream(socket.getOutputStream());	    connector = null;	    LogLog.debug("Connection established. Exiting connector thread.");	    break;	  }	} catch(InterruptedException e) {	  LogLog.debug("Connector interrupted. Leaving loop.");	  return;	} catch(java.net.ConnectException e) {	  LogLog.debug("Remote host "+address.getHostName()		       +" refused connection.");	} catch(IOException e) {	  LogLog.debug("Could not connect to " + address.getHostName()+		       ". Exception is " + e);	}      }      //LogLog.debug("Exiting Connector.run() method.");    }    /**       public       void finalize() {       LogLog.debug("Connector finalize() has been called.");       }    */  }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
美女网站视频久久| 免费欧美高清视频| 裸体歌舞表演一区二区| 成人丝袜视频网| 精品国产一区二区三区忘忧草| 国产精品国产三级国产aⅴ无密码 国产精品国产三级国产aⅴ原创 | 亚洲欧美另类久久久精品| 欧美aaa在线| 欧美日韩国产综合一区二区| 久久久噜噜噜久久人人看 | 在线免费不卡电影| 国产日韩欧美精品在线| 天天亚洲美女在线视频| 色综合天天综合网天天看片| 久久日韩粉嫩一区二区三区| 性久久久久久久久久久久| 99国产精品国产精品毛片| 久久久久久久电影| 免费欧美在线视频| 欧美剧在线免费观看网站| 国产精品久久久久久久久免费桃花 | 亚洲欧美一区二区三区国产精品| 国产一区中文字幕| 欧美日韩免费电影| 亚洲综合小说图片| 欧美伊人久久久久久久久影院| 日韩精品中文字幕在线一区| 夜夜亚洲天天久久| 99久久99精品久久久久久| 久久理论电影网| 国产一区二区精品在线观看| 精品日韩欧美在线| 国产在线精品视频| 国产亚洲综合在线| 久久er99精品| 国产亚洲精品7777| 国产一区二三区| 久久久无码精品亚洲日韩按摩| 久久国产日韩欧美精品| 日韩一区二区三区电影在线观看| 日本亚洲一区二区| 欧美大片一区二区三区| 国产综合久久久久影院| 久久久亚洲精品一区二区三区| 国产麻豆日韩欧美久久| 久久久久亚洲蜜桃| 国产老女人精品毛片久久| 国产亚洲欧美在线| caoporm超碰国产精品| 国产精品日韩成人| 色八戒一区二区三区| 亚洲bdsm女犯bdsm网站| 91精品国产91久久综合桃花| 久久99在线观看| 久久精品一区二区三区av| 成人黄动漫网站免费app| 亚洲欧美一区二区不卡| 欧美影院午夜播放| 麻豆91免费看| 国产日韩欧美不卡| 色综合网站在线| 青青草精品视频| 国产日产欧美一区| 欧美综合在线视频| 精品亚洲porn| 亚洲黄色小视频| 91精品国产乱码| 成人一道本在线| 婷婷综合在线观看| 日本一区二区在线不卡| 欧美视频第二页| 国产做a爰片久久毛片| 中文字幕欧美一| 91精品国产一区二区三区香蕉| 国产福利91精品一区二区三区| 一区二区三区波多野结衣在线观看| 日韩欧美成人一区二区| 91网站视频在线观看| 精品一区二区三区av| 一区二区三区精品| 国产日韩欧美亚洲| 欧美一区二区三区播放老司机| 成人av在线资源网| 乱中年女人伦av一区二区| 亚洲你懂的在线视频| 欧美zozozo| 色88888久久久久久影院按摩| 激情综合色综合久久综合| 一区二区三区欧美激情| 亚洲国产成人av| 亚洲国产精品ⅴa在线观看| 91精品国产美女浴室洗澡无遮挡| 91热门视频在线观看| 国产在线播放一区三区四| 午夜精品123| 一区二区三区不卡视频在线观看| 中文在线资源观看网站视频免费不卡| 欧美精品在欧美一区二区少妇| 99久久精品情趣| 国产成人夜色高潮福利影视| 男女男精品网站| 亚洲成人tv网| 一区二区三区四区国产精品| 中文字幕字幕中文在线中不卡视频| 久久综合精品国产一区二区三区| 欧美一级在线免费| 欧美男人的天堂一二区| 在线观看视频一区二区| 99国产精品一区| 成人app在线| 粉嫩av一区二区三区粉嫩| 国产制服丝袜一区| 国产伦精品一区二区三区免费迷| 久久精品国产亚洲高清剧情介绍| 无码av中文一区二区三区桃花岛| 亚洲国产综合人成综合网站| 一区二区三区日韩在线观看| 亚洲码国产岛国毛片在线| 《视频一区视频二区| 日韩理论片在线| 亚洲码国产岛国毛片在线| 中文字幕一区二区三区精华液| 日本一区二区电影| 国产精品三级av| 亚洲人成在线播放网站岛国| 亚洲精品国产视频| 亚洲一区二区三区四区在线免费观看| 一区二区三区免费| 性久久久久久久久久久久| 亚洲成人黄色影院| 久久99精品久久只有精品| 国产乱码一区二区三区| 国产精品一区二区男女羞羞无遮挡| 东方aⅴ免费观看久久av| 成人免费看视频| 色婷婷综合久久久中文一区二区| 欧美无砖砖区免费| 欧美一区二区三区的| 欧美一区二区三区精品| 国产午夜精品久久久久久免费视 | 亚洲另类一区二区| 夜夜嗨av一区二区三区四季av| 亚洲第一福利视频在线| 久久av资源站| 99热这里都是精品| 欧美日韩视频第一区| 欧美精品一区二区三区在线播放| 亚洲男人的天堂网| 性久久久久久久久| 国产99精品视频| 在线观看一区二区视频| 精品国精品国产| 亚洲精品国产精品乱码不99 | 五月天丁香久久| 国产福利电影一区二区三区| 欧美婷婷六月丁香综合色| 精品剧情v国产在线观看在线| 日韩一区有码在线| 久久国产成人午夜av影院| 一本色道久久综合亚洲aⅴ蜜桃 | 欧美日韩一本到| 久久久久国产精品人| 亚洲国产婷婷综合在线精品| 国精产品一区一区三区mba视频| 91久久一区二区| 国产日韩在线不卡| 男男gaygay亚洲| 91美女精品福利| 久久久久久久性| 亚洲r级在线视频| www.亚洲免费av| 久久奇米777| 日本系列欧美系列| 一本大道av伊人久久综合| 久久综合色综合88| 日本强好片久久久久久aaa| 色婷婷综合久久久久中文一区二区| 久久久久亚洲蜜桃| 久久精品国产第一区二区三区| 色天天综合色天天久久| 久久精品视频在线看| 蜜桃视频一区二区三区在线观看| 欧美综合久久久| 亚洲精品乱码久久久久久| 成人精品电影在线观看| xfplay精品久久| 美日韩一级片在线观看| 欧美日本国产一区| 亚洲一区在线视频| 在线亚洲一区二区| 亚洲人一二三区| 成人av影院在线| 欧美高清一级片在线观看| 成人免费va视频| 国产免费成人在线视频| 丁香婷婷综合激情五月色| 国产香蕉久久精品综合网| 国产91综合网| 国产精品天天看| 99精品视频在线免费观看|