Strange behavior with logger.LogToOperations

Jul 2, 2010 at 2:40 PM

In FeacherActivated use code

          logger.LogToOperations("Start ");
            logger.LogToOperations("TEST", 0, EventSeverity.Information, "PROJECT/Install");
            logger.LogToOperations("End ");
 

but i can see only messages in log Start and End.

I activate Feacher by VS Deploy command, have no errors in output info.

Jul 2, 2010 at 2:42 PM

And in FeacherInstralled calling this code

  private void AddCategories()
        {
            IConfigManager configMgr =
           SharePointServiceLocator.GetCurrent().GetInstance();

            DiagnosticsAreaCollection configuredAreas = new
               DiagnosticsAreaCollection(configMgr);
            foreach (DiagnosticsArea newArea in MyAreas)
            {
                var existingArea = configuredAreas[newArea.Name];

                if (existingArea == null)
                {
                    configuredAreas.Add(newArea);
                }
                else
                {
                    foreach (DiagnosticsCategory c in newArea.DiagnosticsCategories)
                    {
                        var existingCategory = existingArea.DiagnosticsCategories[c.Name];
                        if (existingCategory == null)
                        {
                            existingArea.DiagnosticsCategories.Add(c);
                        }
                    }
                }
            }
            configuredAreas.SaveConfiguration();


        }
Jul 2, 2010 at 3:55 PM

And I'm trying to write into System LOg, not in the SharePOint log.

Jul 6, 2010 at 5:19 PM

Hi,

The issue has to do with filtering levels.  By default the filtering level for events is set to Warning, therefore Informational does not get logged.  If you do not specify a level, then the logger will use the default level of Warning.  You can either change the default level when you create the category by explicitly setting the DefaultEventSeverity to Informational, or you can go into central admin, and change the filter level to Informational, and your messages should show up.

To Configure

Central Admin->Monitoring-> Configure Diagnostics Logging.  You should see your category "Install" under the Area "Project".  Check the "Install" category, and then select the "Least critical event to report to the event log" as "Information", then select the OK button. 

Best Regards,

Chris