Beispiel #1
0
        protected virtual void OpenConnection()
        {
            try
            {
                if (alaClient == null)
                {
                    int    port      = 443;
                    bool   ssl       = true;
                    string debugHost = null;
                    if (!string.IsNullOrWhiteSpace(appender.DebugHTTPReqURI))
                    {
                        var uri = new Uri(appender.DebugHTTPReqURI);

                        if (!string.IsNullOrWhiteSpace(uri.Host))
                        {
                            debugHost = uri.Host;
                        }

                        port = 80;
                        if (uri.Port > 0)
                        {
                            port = uri.Port;
                        }

                        ssl = port == 443 ? true : false;
                    }

                    // Create AlaClient instance providing all needed parameters.
                    alaClient = new AlaTcpClient(appender.SharedKey, appender.WorkspaceId, ConfigSettings.ALAEnableDebugConsoleLog, appender.Name, port, ssl, debugHost); //, (bool)appender.UseSocketPool, (int)appender.MinSocketConn, (int)appender.MaxSocketConn);
                }

                alaClient.Connect();
            }
            catch (Exception ex)
            {
                if (ConfigSettings.ALAEnableDebugConsoleLog)
                {
                    System.Console.WriteLine($@"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffffff")}|Log4ALA|[{appender.Name}]|ERROR|[{nameof(QueueLogger)}.OpenConnection] - [{ex.StackTrace}]");
                }
                throw new IOException($"An error occurred while init AlaTcpClient.", ex);
            }
        }
Beispiel #2
0
        protected virtual void OpenConnection()
        {
            try
            {
                if (alaClient == null)
                {
                    // Create AlaClient instance providing all needed parameters.
                    alaClient = new AlaTcpClient(appender.SharedKey, appender.WorkspaceId, ConfigSettings.ALAEnableDebugConsoleLog, appender.Name); //, (bool)appender.UseSocketPool, (int)appender.MinSocketConn, (int)appender.MaxSocketConn);
                }

                alaClient.Connect();
            }
            catch (Exception ex)
            {
                if (ConfigSettings.ALAEnableDebugConsoleLog)
                {
                    System.Console.WriteLine($@"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffffff")}|Log4ALA|[{appender.Name}]|ERROR|[{nameof(QueueLogger)}.OpenConnection] - [{ex.StackTrace}]");
                }
                throw new IOException($"An error occurred while init AlaTcpClient.", ex);
            }
        }