private void LogMessage(ref Message message, long?idMessage)
        {
            bool enableLog = bool.Parse(Core.Config.Setting.Get(ENABLEWCFLOG, false));

            if (enableLog)
            {
                string callingAddress = OperationContext.Current.IncomingMessageProperties["OriginalHttpRequestUri"] == null ? string.Empty : OperationContext.Current.IncomingMessageProperties["OriginalHttpRequestUri"].ToString();
                string operationName  = string.Empty;
                if (!string.IsNullOrEmpty(callingAddress))
                {
                    operationName = callingAddress.Substring(callingAddress.LastIndexOf("/", StringComparison.Ordinal) + 1);
                }

                //foreach (var item in OperationContext.Current.IncomingMessageProperties)
                //{
                //    System.Diagnostics.Debug.WriteLine(string.Format(" {0} - {1}", item.Key, item.Value));
                //}

                IWcfLogService logService = ObjectFactory.GetInstance <IWcfLogService>();
                string         msg        = MessageToString(ref message);
                if (logService != null)
                {
                    if (!idMessage.HasValue)
                    {
                        _idLogMessage = logService.LogRequest(operationName, callingAddress, msg);
                    }
                    else
                    {
                        logService.LogResponse(_idLogMessage, msg);
                    }
                }
            }
        }
예제 #2
0
 internal static void LogWithoutException(this IWcfLogService logService, AbstractLogInfo log)
 {
     try
     {
         logService.Log(log);
     }
     catch (Exception ex)
     {
         LocalLogService.Log(ex.ToString());
     }
 }
예제 #3
0
        private void CreateProxy()
        {
            Validate.Value.IsNotDisposed(this, nameof(WcfLogClient));

            this.proxy = this.proxyFactory.CreateChannel(this.proxyFactory.Endpoint.Address);

            this.channel = this.proxy as IChannel;
            if (this.channel == null)
            {
                throw new InvalidOperationException();
            }

            this.channel.Open();
        }