private static void SetDeveloperDashBoardDisplayLevelSetting(ISharePointCommandContext context, string newLevel) { try { SPDeveloperDashboardLevel level = ((SPDeveloperDashboardLevel)Enum.Parse(typeof(SPDeveloperDashboardLevel), newLevel)); SPDeveloperDashboardSettings settings = context.Site.WebApplication.WebService.DeveloperDashboardSettings; settings.DisplayLevel = level; settings.Update(true); } catch (ArgumentNullException ex) { context.Logger.WriteLine(String.Format(Resources.DeveloperDashboardCommands_SetException, ex.Message, Environment.NewLine, ex.StackTrace), LogCategory.Error); } catch (ArgumentException ex) { context.Logger.WriteLine(String.Format(Resources.DeveloperDashboardCommands_SetException, ex.Message, Environment.NewLine, ex.StackTrace), LogCategory.Error); } catch (OverflowException ex) { context.Logger.WriteLine(String.Format(Resources.DeveloperDashboardCommands_SetException, ex.Message, Environment.NewLine, ex.StackTrace), LogCategory.Error); } }
static void Main() { SPDeveloperDashboardSettings settings = SPWebService.ContentService.DeveloperDashboardSettings; settings.DisplayLevel = SPDeveloperDashboardLevel.On; settings.TraceEnabled = true; settings.Update(); }