locked
Write WCF error message to log file in WCF service! RRS feed

  • Question

  • User-34860367 posted

    Hi all,

    I am not sure how to write the error message to log file. Here is my WCF service file as folllowing:

    namespace WcfServiceGetNodeValues

    {

    public class GetNodeValueService : IGetNodeValueService
    {
           public bool ValidateStrXml(string strXml)

           {
               try
               {
                      XmlDocument myDoc = new XmlDocument();
                      myDoc.LoadXml(strXml);
                      return true;
               }
              catch (XmlException ex)
              {
                    GetFaultMsg(ex.Message.ToString());
                    return false;
               }

           }

          public string GetFaultMsg(string error)

          {
                 string customFaultmsg = "Write error into log file: " + error;
                 return error;
           }

    }

    I really appreciate your time to help me on this issue and how do I can get the error message is displayed from client. Thanks in advance. 

    Monday, February 4, 2013 9:20 PM

Answers

  • User-34860367 posted

    Hi,

    I figured out how to write the error message to log file. Used this link http://niksonpaul.wordpress.com/2011/12/12/c-logger-create-your-own-exception-log-file/ for adding codes to:

          public string GetFaultMsg(string error)

          {
                 string customFaultmsg = "Write error into log file: " + error;
                 return error;
           }

    This solved my issue.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 5, 2013 8:20 PM

All replies

  • User-34860367 posted

    Hi,

    I figured out how to write the error message to log file. Used this link http://niksonpaul.wordpress.com/2011/12/12/c-logger-create-your-own-exception-log-file/ for adding codes to:

          public string GetFaultMsg(string error)

          {
                 string customFaultmsg = "Write error into log file: " + error;
                 return error;
           }

    This solved my issue.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 5, 2013 8:20 PM
  • User-1000095884 posted

    Hi,

    Thanks for your feedback and share the solution here.

    Best Regards.

    Tuesday, February 5, 2013 10:40 PM