I asked some of the same questions when I started working with PowerShell. It’s not a simple topic; there are 5 streams (6, if you count the Progress stream) that can all produce host output in different ways (Output, Warning, Verbose, Error, and Debug). It’s tricky to make sure you catch everything and get it into your log file, and even more tricky if you want to see it at the console at the same time.
The simplest way to get everything into a log file (in PowerShell 3.0), is to use the *> redirection operator, but then you won’t see the output at the console.
Do-Something *> .\output.log
I wound up writing two modules for logging behavior to help with this in my scripts; the C# version is a bit more hands-off, but is also more likely to break on occasion, when Microsoft releases PowerShell updates (because it fiddles with private members of the PowerShell host to intercept console output.) They’re both available over on the TechNet repository: http://gallery.technet.microsoft.com/scriptcenter/Enhanced-Script-Logging-27615f85 and http://gallery.technet.microsoft.com/scriptcenter/Write-timestamped-output-4ff1565f
They make it fairly easy to accomplish thorough logging without much effort in your code, particularly the C# one. Here’s an example:
$logFile = Add-LogFile -Path '.\output.log'
# Run all your other script code here, no changes required.
# Anything that goes to the screen will wind up in the log file (except for the Progress stream, which is not really useful in a log).
# The module automatically prepends timestamps to non-blank lines, and indicates which stream produced the output. ([V] for Verbose, [D] for Debug, etc.)
# At the end of your script, stop the logging:
$logFile | Disable-LogFile