Code:
on *:join:#:{
  if ($nick == $me) { 
    .log on # -f # $+ .txt
  }
}


That will automatically log the channel you join as #channelname.txt, so if you join #mIRC it will log as #mIRC.txt in your default logs directory.