Logging

SMTP Impostor uses System.Diagnostics.Trace for logging activity
to enable logging you need to add a listener to the config file

  <system.diagnostics>
    <trace autoflush="true">
        <listeners>
          <add 
              name="File" type="System.Diagnostics.TextWriterTraceListener" 
              initializeData="C:\temp\Impostor.Log" /> 
        </listeners>
    </trace>
  </system.diagnostics>

make sure the application has write access to the log file

for the standard client installed by ClickOnce you have to find the install dir, this can be done by;
  1. run the Impostor client
  2. open Windows Task Manager
  3. find the process Antix.Mail.Smtp.Impostor.Client.exe and click properties
  4. the location is shown on the General tab

If you are referencing SMTP impostor you can also change how logging is done, the static class Log has a number of "Action" properties which you can set to a lambda to call Log4Net or what ever you like.

        [TestMethod]
        public void LogExceptionOverridenAction() {
            var log = new StringBuilder();

            Log.LogErrorAction = (f, a) => {
                                     log.AppendLine(DateTime.Now.ToString());
                                     log.AppendLine(string.Format(f, a));
                                 };

            try {
                throw new Exception(EXCEPTION_TEXT);
            }
            catch (Exception ex) {
                Log.Error("LogException {0}", ex);
            }

            Assert.IsTrue(log.Length > 0);
            Assert.IsTrue(log.ToString().Contains(EXCEPTION_TEXT));
        }

Last edited May 6, 2011 at 4:29 PM by Antix, version 1

Comments

No comments yet.