This project is read-only.

Samples

Jan 17, 2012 at 11:49 AM

Hi,

Could you provide us more samples or documentation for the API? Some sample project included in the downloads would be nice.

For example to log (in an application page) I've done this and it won't fully work:

In a farm scoped feature's event receiver initialize farm environment like shown in beta 3 release notes (http://blog.sharepointpress.com/post/CKSAPI-Beta-3-Release-Notes.aspx).

From Central Administration diagnostic logging settings I've changed the least critical levels to Verbose after the farm scoped feature has been activated.

In an application page's event handler I try to use the logging by creating new instance of CKSFarmLogger. I've tried to use current SPSite and Central Administration site collection and only Error-level entries are written to event log. Also HandleException won't show up in StatusBar or as a dialog window, entry is written to event log though:

            SPSite site = SPContext.Current.Site;
            SPWeb rootWeb = site.RootWeb;
            var logger = new CKSFarmLogger(rootWeb, false);
            
            try
            {
                if (e.CommandName == "Button1") // event log
                { 
                    logger.Write("CKS - Log entry test 1 - Default."); // won't show up
                    logger.Write("CKS - Log entry test 2.", CKSLoggingCategory.ApplicationPage, LoggingSeverity.Error);
                    logger.Write("CKS - Log entry test 3.", CKSLoggingCategory.ApplicationPage, LoggingSeverity.Information); // won't show up
                }
                else if (e.CommandName == "Button2") // throw exception
                {
                    throw  new Exception("Foo error.");
                }
            }
            catch(Exception ex)
            {
                logger.HandleException(new CKSExceptionDetails(ex, CKSLoggingCategory.ApplicationPage)
                                           {
                                               Display = ErrorDisplayType.StatusBar,
                                               ThrowingControl = this,
                                               UserText = "Friendly message!"
                                           });   
            }

 

 

 

Jan 20, 2012 at 1:32 PM

Let me take a look and see what might be going on.  I'll post something back here as soon as I can.

 

Dave

May 22, 2012 at 3:57 AM

Have you initalised the SiteCollectionEnvironment of the FarmLogger for the SiteCollection containing this page? I had a similar issue which activating the following feature solved (along with ensuring that Verbose level messages got written to the trace.

 

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
    base.FeatureActivated(properties);
    var site = properties.Feature.Parent as SPSite;
    var logger = new CKSFarmLogger(site.RootWeb,false);
    logger.InitializeSiteCollectionEnvironment();
}