Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a SharePoint 2010 solution which deploys some custom controls to the ControlTemplates directory (via mapped folder) and a site scoped feature with a feature receiver class that makes some updates to the site. Everything is working fine except my logging. I'm using the same type of logging commands in both the feature receivers and my custom controls but for some reason, the log entries are showing up in the ULS logs for the feature receivers but not for the custom control code. I've debugged and stepped through the code and no exceptions are thrown, the entries from the custom control code are just not showing up. Here's the type of command I'm using:

SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory("My Controls", TraceSeverity.High, EventSeverity.ErrorCritical), TraceSeverity.High, "An error occurred while rendering the custom control: {0}", ex.ToString());

I've verified that the application pool's account belongs to the Performance Log Users group as I thought it may be a permission issue.

Any ideas why my logging works from a feature receiver class but not from the code of my custom control?

share|improve this question
add comment

1 Answer

Can you try to see if the following works for you?

try
{
}
catch (Exception ex)
{
    SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory("My Controls", TraceSeverity.High, EventSeverity.ErrorCritical), TraceSeverity.High, ex.Message, ex.StackTrace);
}

or

try
{
}
catch (Exception ex)
{
    SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory("My Controls", TraceSeverity.High, EventSeverity.ErrorCritical), TraceSeverity.High, "An error occurred while rendering the custom control: ", new object[] { ex.StackTrace});
}

hope it helps :)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.