示例#1
0
        /// <summary>
        /// Construct the sls client with accessId, accessKey and server address,
        /// all other parameters will be set to default value
        /// </summary>
        /// <param name="endpoint">the sls server address(e.g.,http://cn-hangzhou.sls.aliyuncs.com)</param>
        /// <param name="accessKeyId">aliyun accessId</param>
        /// <param name="accessKey">aliyun accessKey</param>
        public LogClient(String endpoint, String accessKeyId, String accessKey, String securityToken)
        {
            if (!endpoint.StartsWith("http://") && !endpoint.StartsWith("https://"))
            {
                endpoint = "http://" + endpoint;
            }
            setEndpoint(endpoint);
            if (IpUtils.IsIpAddress(this._hostName))
            {
                throw new LogException("LogClientError", "client error happens");
            }

            _localMachinePrivateIp = IpUtils.GetLocalMachinePrivateIp();
            _accessKeyId           = accessKeyId;
            _accessKey             = accessKey;
            _securityToken         = securityToken;
            serviceClient          = ServiceClient.Create(new ClientConfiguration());
            serviceClient.Configuration.ConnectionTimeout = LogConsts.DEFAULT_SLS_CONNECT_TIMEOUT;
            serviceClient.Configuration.ReadWriteTimeout  = LogConsts.DEFAULT_SLS_READWRT_TIMEOUT;
        }