Showing posts with label Trace Logs. Show all posts
Showing posts with label Trace Logs. Show all posts

Wednesday, April 30, 2014

Correctly configuring the Diagnostic Levels in SharePoint 2013

When things aren't going right and you post your problem to the forums, what do they always say? Check the logs! That's because you can use SharePoint 2013 Unified Logging Service (ULS) logs when troubleshooting. But... there are a lot of ways to configure those logs and for the 70-331 exam and the real world, you will want to take a look at some best practices:

Change where the server writes logs.
By default, SharePoint 2013 writes diagnostic logs to the installation directory, ie "%CommonProgramFiles%\Microsoft Shared\Web Server Extensions\15\Logs"
Logs take space, and it would be pretty awful if you were resolving a SharePoint issue by enabling more logging only to cause additional problems because of your logging! Therefore, we should configure logging to write to a different drive by using the following PowerShell command:

Set-SPDiagnosticConfig -LogLocation <PathToNewLocation>


Note: The location that you specify must be a valid location on all servers in the server farm, and watch out for slow connections to network disk paths, especially if you enable verbose-level logging

Define a maximum for log disk space usage.
How much of your disk will the logs use? Imagine Sesame Street's Cookie Monster is the ULS logging service and your disk is a cookie. ULS logging in unrestricted by default in disk consumption. So the best practice is to restrict the disk space that logging uses, especially in verbose-level logging situations, so that when reaching maximum defined capacity the ULS service will remove the oldest logs before it recording new log data.
Configure logging restrictions using the following PowerShell commands:
Set-SPDiagnosticConfig -LogMaxDiskSpaceUsageEnabled
Set-SPDiagnosticConfig -LogDiskSpaceUsageGB <UsageInGB>


These two settings can be done in central administration in "Configure Diagnostic logging" settings
Also, don't forget that you can enable Event Flood Protection to suppress repeated events from overflowing a log that is configured to be circular

Set-SPDiagnosticConfig -EventLogFloodProtectionEnabled





Choose your ULS logging levels carefully, especially Verbose
Also called "event throttling" this is where you choose the depth of data collection for the ULS (trace logs) and the event logs. The Trace Log levels are described below.

Typical Production settings will max out at collecting Medium Logging. Minimum Logging would be "Unexpected" Maximum Logging is Verbose which records every action, quickly eating drive space. Use verbose-level logging to record detail when making critical changes and then reset to a lower logging level.


Similar precautions need to be taken for the Event Logging Levels:


To Set Event Throttling use Diagnostic Logging in Central Administration or the PowerShell cmdlets:
To set all levels:
Set-SPLogLevel -EventSeverity <level>
Set-SPLogLevel -TraceSeverity <level>

To set both for one category you could use the following
Set-SPLogLevel -EventSeverity <level> -TraceSeverity <level> -Identity "<category>"

For example:
Set-SPLogLevel -EventSeverity warning -TraceSeverity high -Identity "Search"
 



Regularly back up logs.
Diagnostic logs contain important data. Therefore, back up the logs regularly to ensure that this data is preserved. Use your backup software against the log directory.

Read the Logs:
Viewing the Logs: You can use Windows PowerShell to filter the data, display it in various ways, and output the data to a data grid with which you can filter, sort, group, and export data to Excel 2013.

Get all the logs: (tmi!)

Get-SPLogEvent

Get filtered Log info: 

Get-SPLogEvent | Where-Object {$_.<eventcolumn> -eq "value"}

By area:
Where-Object {$_.Area -eq "SharePoint Foundation"}


By level:
Where-Object {$_.Level -eq "Information" }


By category:
Where-Object {$_.Category -eq "Monitoring"}


Search for text:
Where-Object {$_.Message -like "people"}


Output to a graphical grid - use the filtered search then pass results to out-gridview cmdlet
Get-SPLogEvent | Where-Object {$_.Area -eq "Search"} | Out-GridView



Of course you could also download the ULS viewer from codeplex to aid in viewing logs. More info on that here: 
http://majorbacon.blogspot.com/search/label/ULS

Happy Logging!
 

Thursday, April 3, 2014

SharePoint is trying to tell you something. Use the ULS viewer to find out what!

Unified Logging Service in SharePoint is great, but you need a way to view the logs. Enter ULS Viewer - a free tool you can download from Microsoft CodePlex in order to debug a SharePoint environment. Keep in mind that it can only log what it receives, so when you have networking problems or even IIS problems that come before SharePoint, your ULS logs won't have much to tell you. But when you've just deployed a new feature or web app and now your having a meltdown, you should definitely take a look using this tool. And the features!
  • View multiple SharePoint log files at once
  • Search by any field
  • Filter the log by any field
  • File drag & drop support
  • Live monitoring for entire farm
  • Export filtered log entries
  • Bookmark log entries
  • Get popup notification of SharePoint log events from system tray
  • Receive email notifications on errors
  • Redirect log entries to event log
  • Supports SharePoint 2007, 2010 and 2013
System Requirements:
  • .NET Framework 3.5
  • Windows XP or above
Download the ULS Viewer here: Download ULS Viewer
You will probably want to launch the tool as an admin.
Open the Viewer and from the file menu choose "Open From", then "ULS":


You can reference the default SharePoint ULS logs location or an alternate location:





The Logs will show you what is going in the mind of SharePoint. You can filter to "Show High Messages" which will reference ony high priority errors