Better ULS Logging in PowerShell

Stumbled upon this post when trying to use the ULS logger to see an error:

http://www.habaneroconsulting.com/insights/An-Even-Better-Way-to-Get-the-Real-SharePoint-Error#.UvVtBPldV8E

See the blog above for full details but here is a simplified way to get an error:

1. Get correlation id from window

2. in PowerShell (run the following commands):

Merge-SPLogFile -Path “.\error[x].log” -Correlation “85ea729c-071c-d0b1-d6c7-065c6284a50f”

Dir *.log

I name my log errorx where x is a number and delete them after I I’m done.

Saves to C:\Users\ [your user name]

3. Open ULS Viewer > Open File and select error[x].log

Way easier than hunting through ULS logs.

Content Query ‘No results” message

By default Content Query Web Parts (CQWP) don’t display any text on a page when no results are returned. The message is only displayed in “edit mode” when a content manager or developer is editing the page. This can be frustrating because you might want to display a message that says that nothing has been returned. In my case we wanted to query a calendar for upcoming events that meet some conditions and a message if there wasn’t any. The solution is simple:

1. Open Designer and your root site collection (http:// [site collection name])

2. Select All Files > Style Library > XSL Style Sheets

3. Open ContentQueryMain.xsl  (good idea to make a copy called custom)

4. Look for the item template OuterTemplate.Empty:

contentQuerymain

Note the xsl:if tag that indicates that the message will only be shown when in edit mode. Add a custom message above.