次の方法で共有


Understanding Commands: Logging Commands

Command:  log; Tools.LogCommandWindowOutput
Versions:  2008,2010
Published:  8/12/2010
Code:  vstipTool0071

 

Folks I want to get your input on the possible title for the new book.  Give me your comments at https://blogs.msdn.com/b/zainnab/archive/2010/08/09/proposed-book-title.aspx

 

When using commands sometimes you want to keep a log of the ones you used.  This is especially useful when you are experimenting with commands to see what iterations you went through.  Here is the syntax for logging:

 

log [filename] [/on|/off] [/overwrite]

or

Tools.LogCommandWindowOutput [filename] [/on|/off] [/overwrite]

 

 

 

Filename

It's highly recommended that you use a path and filename otherwise the default filename is cmdline.log and the log file is stored at C:\Users\<user>\AppData\Roaming\Microsoft\VisualStudio\<version>:

image 

 

/on /off

Turns on or off logging respectively.

 

/overwrite

By default, all logging will append to your log file.  The /overwrite switch will change this behavior and erase any previous commands from the log when a new log session is started.

 

 

 

Let's do an example.  I'll start logging in my Command window (CTRL + ALT + A) and specify a filename by typing  "log C:\Users\<user>\Documents\vslog.txt /on":

image

 

Now I'll type in a couple of commands.  The commands don't matter here so feel free to substitute your commands in place of mine if you want.  The commands I will use will be "View.ViewCode" to get a code window and "Edit.Find sys" to find some text:

image

 

Since I'm done, I'll turn logging off by using the "log /off" command:

image

 

Now I can go to My Documents and see the file:

image

 

And if we open the file, this is what we get:

image

 

And there you go!  Command logging at it's best.