I had a question from a customer recently about increasing the verbosity of their SharePoint ULS logs. The customer was having issues with a known issue, and wanted to know if there was a way to capture more verbose information to assist with troubleshooting.
I came up with the idea of increasing the verbosity level with a PowerShell script; and using Windows Scheduled Tasks to run the script when the event ID was generated in the event logs.
I’m sure you all know how to create a scheduled task, so I won’t go through the details here, but below is a screenshot showing where the ‘trigger’ is configured.
The script does a couple of things before raising the logging level to Verbose. Firstly, it checks what the current logging level is; e.g. if it is already Verbose, then it’s not going to do much J
Secondly it writes out to the event log to record that the increase has been made.
It waits for ‘xxx’ number of seconds, and then performs two final actions
1 – Sets ULS logging severity back to whatever it was
2 – Writes to the event log letting you know that it has rolled back the ULS severity change.
To be a good citizen, here are a couple of screen shots showing the log entries:
Here is the initial log entry:
And then when the logging change is reverted:
Hope you find it useful, cheers.
Steve – @moss_sjeffery