none
simple way to make a log file

    Pertanyaan

  • I have a smart device application. I would like to create a log file that will keep track of everything the application does. I am not sure where to start. I do not need instructions on how to read/write to a file. 
    14 Februari 2012 21:24

Semua Balasan

  • 15 Februari 2012 6:57
  • I am trying the code from the link: GlobalCache.Instance.AppPath

    Error 13 The name 'GlobalCache' does not exist in the current context

    public void LogErrors(Exception ex)
            {
                StreamWriter _sw = null;

                try
                {
                    //Instantiate an appendable streamwriter that writes to a file called ErrorLog.txt
                    _sw = new StreamWriter(GlobalCache.Instance.AppPath + "ErrorLog.txt", true, System.Text.Encoding.ASCII);
                    //Write a row of data containing the time, the error message, and the stack trace
                    _sw.WriteLine("* " + System.DateTime.Now.ToString() + " | " + ex.Message + " | " + ex.StackTrace);
                }
                finally
                {
                    //Ensure the streamwriter gets closed
                    if (_sw != null)
                    {
                        _sw.Close();
                        _sw = null;
                    }
                }
            }

    21 Februari 2012 20:48
  • Hi,

    It looks the ClobalCache class is not available in your build. Please remove GlobalCache.Instance.AppPath and directly place your path.


    -Malleswar

    24 Februari 2012 16:25
  • Hi,

    Im not sure exactly what it is you wish to log but the .netcf framework provides the ability to enable logging of various things.

    See:- http://msdn.microsoft.com/en-us/library/ms229650(v=vs.90).aspx

    Hope this helps.

    27 Februari 2012 12:11