web service dose not work,help

3 messages Options
Embed this post
Permalink
phil

web service dose not work,help

Reply Threaded More More options
Print post
Permalink
Hi

I am new to the Nlog and try use web service to save error log using NLog.it seems dose not work for me

Does any one can help me to figure it out

Thanks a lot

phil

here is my NLog.config file


<?xml version="1.0" encoding="utf-8" ?>
<!--
  This file needs to be put in the application directory. Make sure to set
  'Copy to Output Directory' option in Visual Studio.
  -->
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <targets>
    <target name="ws" xsi:type="WebService"
        namespace="http://tempuri.org/" protocol="Soap11"
        methodName="ErrorLog" url="http://10.1.1.4/service/LogError.asmx">
      <parameter name="strApplicationIdentifier" type="System.String" layout="${aspnet-application:variable=appid}"/>
      <parameter name="strServerName" type="System.String" layout="${aspnet-request:serverVariable=SERVER_NAME}"/>

      <parameter name="strServerIP" type="System.String" layout="${aspnet-request:item=UserHostName}"/>
      <parameter name="strLogLevel" type="System.String" layout="${level}"/>
      <parameter name="strTrackTrace" type="System.String" layout="${stacktrace:format=Raw}" />

      <parameter name="strQueryString" type="System.String" layout="${aspnet-request:querystring}" />
      <parameter name="strUrl" type="System.String" layout="${aspnet-request:item=Url}" />
      <parameter name="dtIncidentDate" type="System.String" layout="${date:format=MM-dd-yyy HH\:mm\:ss.fff}" />
      <parameter name="strMessage" type="System.String" layout="${message}" />
      <parameter name="strSource" type="System.String" layout="${exception:format=Source}" />
      <parameter name="strForm" type="System.String" layout="${aspnet-request:form}" />
      <parameter name="strTargetSite" type="System.String" layout="${exception:format=TargetSite}" />
      <parameter name="strReferringSite" type="System.String" layout="${aspnet-request:item=UrlReferrer}" />
      <parameter name="strIPAddress" type="System.String" layout="${aspnet-request:item=UserHostName}" />
      <parameter name="strInnerException" type="System.String" layout="${exception:format=InnerException}" />

</target>
  </targets>

  <rules>
    <logger name="*" minlevel="Error" writeTo="ws" />
  </rules>
</nlog>


the page_load function is



 try
            {

                HttpContext.Current.Application["appid"] = "application";

                throw new Exception("[data.txt not in c:\\dev directory]");
           



            }
            catch (Exception ex)
            {

                Logger logger = LogManager.GetCurrentClassLogger();
            }


phil

Re: web service dose not work,help

Reply Threaded More More options
Print post
Permalink
ok, finally i figure it out.

set  Copy always to NLog.config.

But i still get some problem.

for this parameter

<parameter name="strIPAddress" type="System.String" layout="${aspnet-request:item=UserHostName}" />

I still can not get the value.

dose any one know it.

Thanks a lot

Phil
phil

Re: web service dose not work,help

Reply Threaded More More options
Print post
Permalink
also How can i get Exception.source value using  exception layout?

Thanks

Phil