Friday, August 1, 2014

Implementing ELMAH (custom logging) in SharePoint 2013

ELMAH (Error Logging Modules and Handlers) is an application-wide error logging facility that is completely pluggable. It can be dynamically added to a running ASP.NET web application, or even all ASP.NET web applications on a machine, without any need for re-compilation or re-deployment.

We can implement Elmah in our SharePoint application. Following are the steps to implement elmah in SharePoint application -

1. Download  ELMAH 1.2 Service Pack (SP) 2 from below link

http://code.google.com/p/elmah/wiki/Downloads

2. Download Setups for 64-bit Windows (.NET Framework 4.0) - (sqlite-netFx40-binary-x64-2010-1.0.93.0.zip  )      

http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki

3. Create a database named ELMAH_customlogging into the Microsoft SQL Server

4. The ELMAH download includes a file named SQLServer.sql . Run this script against database that we have created in above steps. This script will create tables for ELMAH for error logging.
 5. Create a empty SharePoint solution and a reference of elmah.dll and system.data.sqlite.dll

6. Add a Visual webpart and write a code to throw an exception to check weather elmah logged that error or not.

7. Following are the config entries that needs to added in web.config of the web application

Add under configsection
<configSections>
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
</sectionGroup>
</configSections>

Add connectionstring section 

<connectionStrings>
<add name="elmah-express" connectionString="Data Source=[server name];Initial Catalog=[ELMAH_customlogging];User ID=testuser;Password=Welcome1;" />

</connectionStrings>

Add elmah section just below the connectionstring section
<elmah>
<security allowRemoteAccess="0" />
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="elmah-express" />
</elmah>

Add handler and module entry in httphandlers and httpmodules section under system.web

<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah"/>
</httpHandlers>

<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
</httpModules>

Add handler and module entry in handlers and modules section under system.webserver

<modules runAllManagedModulesForAllRequests="true">


<remove name="ErrorLog"/>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
<add name="ErrorTweet" type="Elmah.ErrorTweetModule, Elmah" preCondition="managedHandler" />
</modules>
<handlers>

<add name="Elmah" path="elmah.axd" verb="POST,GET,HEAD" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
</handlers>

8. After adding config entries deployed the webpart and that webpart on the SharePoint page.

9. Open the SharePoint page which will throw the exception as we have added the exception in the webpart.

10. Now to check the error log open the elmah.axd
      like
https://webapp/sites/sitename/elmah.axd

 11. SQL server view


Please refer below link for reference
http://www.codeproject.com/Articles/186237/Exception-logging-using-Elmah-Error-Logging-Module

Sunday, June 22, 2014

Records management (SharePoint Server 2010)


record is a document or other electronic or physical entity in an organization that serves as evidence of an activity or transaction performed by the organization and that requires retention for some time period.
Records management as “the practice of maintaining the records of an organization from the time they are created up to their eventual disposal.      
Records management is the process by which an organization:
•      Determines what kinds of information should be considered records.
•      Determines how active documents that will become records should be handled while they are being used, and determines how they should be collected after they are declared to be records.
•      Determines in what manner and for how long each record type should be retained to meet legal, business, or regulatory requirements.
•      Researches and implements technological solutions and business processes to help ensure that the organization complies with its records management obligations in a cost-effective and non-intrusive way.
Performs records-related tasks such as disposing of expired records, or locating and protecting records related to external events such as lawsuits.

Two Types of Record Management in 2010
SharePoint 2010 introduces new capabilities regarding Records Management. The most interesting feature, I think, is In-Place Records management (info at the end of this post) which makes it possible to declare documents as records without moving them to a Records Center. Records and documents live side by side in the site they were created in, and SharePoint 2010 makes it possible to apply different policies (i.e. retention schedules) depending if the item is a record or a document.

The Record Center site template is still available. It utilizes some new functionality like the Content Organizer to route incoming documents to the libraries of your preference. A new “dashboard” gives a record manager faster access to common tasks and to-do actions.
Holds (with discovery), audit and file-plan reports are also new or improved functionality to better control your records.
Other items than documents can also be declared as records in SharePoint 2010; wiki pages, blog posts, article pages among others.

In-Place Records Management
A new capability in SharePoint 2010 is In-Place Records management. Instead of moving a document to a specific Records Center, you declare the document as a record and it will be handled as a record in the site it was created in. After the document is declared as a record, it can have policies and restrictions different than when it was a document. The policies are added to either the Content Types or directly on the document libraries (see the Retention Schedule paragraph above).

Documents can be declared as records either manually or automatically.
Manual record declaration can be configures on Site Collection level and overridden in each document library. In Site Collection settings you have the following options on how declarations of records should be done:

When Record Declaration Availability is set to “Available in all location by default”, a new icon appears on the Ribbon:

A document will get a padlock added to its icon when declared as a record:
Again, you can override the record declaration availability on the document library level:
Automatically declarations of records are possible by checking the “Automatic Declaration” option in the document library settings.

Declaring documents as records means the documents are final and should not be modified for compliance reasons. In SharePoint 2010, documents can be declared as records in two ways
1. Select one or more documents (yes, you can multi-select documents! and apply actions such as check-in/out) and then declare them as records! Done.  these documents cannot be updated. Of course, some pre-configuration is required, but this is quite easy and more importantly out-of-the-box feature from SharePoint 2010

2. Another way is to select the documents and then to send them to a special site called records center site. The documents will be copied to the records center site and links will be displayed in the document library where the documents were originally located.

Folders or content types
You can define retention policies based on an item’s content type or based on the folder in which an item is located  any given library, you must select one or the other. You cannot base retention policies on a combination of content types and folders within the same library.
Your choice will greatly affect how you set up the site and how users use the site. It is usually simpler to base retention policies on content types, if this works in your situation.







Welcome to SharePoint Server 2019, a modern platform for choice and flexibility

“Without continual growth and progress, such words as improvement, achievement, and success have no meaning.” Benjamin Franklin Thi...