I'm trying to troubleshoot some events in my logs and need to figure out what web application is associated to the GUID the logs reference.
Anyone know how I can generate the GUID for each of my web applications?
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.Sign up to join this community
You can use following PowerShell command to know all your Web Application's GUIDs.
Get-SPWebApplication | Select DisplayName, Id
However, bear in mind that, the GUIDs for each item in ULS logs are unique (typically for one unit of operation - like one page request) and they do not correspond directly to GUIDs of web application, unless the log suggests so.
To generate a GUID (in Powershell) -
$fooGuid = [guid]::NewGuid()
Visual Studio also has the 'Create GUI' option under the Tools menu.
This Powershell command (mentioned by Ashish above) gives you the Web App name and its ID (GUID) -
$apps = Get-SPWebApplication | Select DisplayName, Id
and to extend more to the above by using PowerShell with the ULS Log files (using the Get-SPLogLevel/Set-SPLogLevel cmdlets) - this post may be helpful - SharePoint 2010 Logging Improvements – Part 1
If you are talking about the "Correlation" column in the log file, that info isn't related to the web application in any way (or at last - not in any documented way that I know of, it may still be possible that the ID is somehow calculated using some info from the web application identity).
That said, the correlation identifier is simply a GUID that is automatically generated for every request that the SharePoint web server receives. This identifier is also persisted and used in any further communication between server that the request may generate. From an user point of view this means that it's possible to track down any log records that where generated by a single request. Probably you have already saw it, but whenever SharePoint shows an error page it includes a "correlation id". Simply copy that id, search it in the log file (or use a tool like SharePoint Uls Viewer) and you will be able to filter out the records that contain info about the offending request.
As a developer you can include the current correlation id in any message you may be generating (this can help you to find the info you need), but the only way to do so that I know of is to use an external reference.
Anyway, this blog post should provide further info: link
To elaborate some more: If you need to somehow include a web application identifier in your log messages, you will need to do this "by yourself" - SharePoint does not include this information by default. That would not be a problem if you are generating the log record (simple include a web app identifier in the log info, even the web application description would do), but could be a problem if you are tracking some ootb log error messages. In that case, my suggestion would be to resort to the correlation id that should be displayed in the UI or backtrack the error based on the execution time - either way it shouldn't be possible to associate the correlation id (or the event/thread identifiers) to a specifi web app.