コード例 #1
0
        private WcfAppenderClient CreateProxyInstance()
        {
            EndpointAddress endpoint = new EndpointAddress(RemoteAddress);
            WSHttpBinding binding = new WSHttpBinding(SecurityMode); ;

            WcfAppenderClient client = new WcfAppenderClient(binding, endpoint);
            client.ClientCredentials.UserName.UserName = Username;
            client.ClientCredentials.UserName.Password = Password;

            return client;
        }
コード例 #2
0
        private void FlushQueue()
        {
            try
            {
                LoggingEventContainer[] container = new LoggingEventContainer[_eventQueue.Count];
                LoggingEvent[] events = _eventQueue.ToArray();

                for (int i = 0; i < events.Length; i++)
                {
                    LoggingEvent loggingEvent = events[i];
                    container[i] = new LoggingEventContainer()
                                       {
                                           Domain = loggingEvent.Domain,
                                           Exception = loggingEvent.GetExceptionString(),
                                           Identity = loggingEvent.Identity,
                                           LogLevel = loggingEvent.Level.ToString(),
                                           LoggerName = loggingEvent.LoggerName,
                                           Message = loggingEvent.RenderedMessage,
                                           ThreadName = loggingEvent.ThreadName,
                                           Timestamp = loggingEvent.TimeStamp
                                       };
                }

                ProxyInstance.AppendLoggingEvents(container);
                _eventQueue.Clear();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            //a proxy can only fault once. an exception will cause the proxy to transition
            //to faulted state and we have to create a completely new instace of the proxy (done in the property)
            if (_proxyInstance != null && _proxyInstance.State == CommunicationState.Faulted)
            {
                _proxyInstance = null;
            }
        }