code:
function OnEvent_ChatWndRecieveMessage(ChatWnd, Origin, Message, MessageKind);
{
   var ChatWnd;  //a reference to the window that recieved the msg is stored here
   if (Origin != Messenger.MyName)//check if the message came from you
   {
      if (LogFileExists(ChatWnd);)//Check if the window already has a log file
      {
         addToLogFile(ChatWnd, Message);//add the recieved msg to existing log file
      }
      else if (!LogFileExists(ChatWnd);)//if window doesn't have a log...
      {
         createLogFile(ChatWnd);//create one
      }
   }
}
obviously, make functions using file system objects for log creation, adding to, etc. and use similar technique to delete the file after OnEvent_ChatWndDestroyed();
hope that gets ya going again! :)