Extend a Sitecore Pipeline

Extending one of Sitecores pipelines with some custom code is straightforward. Just remember that to extend the pipeline at the right spot making sure that Sitecore has generated the data you need to use. If you extends the httpRequestBegind pipeline, you will not be able to get any data about the requested item before the Sitecore.Pipelines.HttpRequest.ItemResolver has finished etc.

Create your custom code and letting your class inheriting from Sitecore.Pipelines.HttpRequest.HttpRequestProcessor (In the case of extending the httpRequest pipeline):



The next step you need to do is to add your extension into the settings of the httpRequestBegin pipeline as a new processor. In this case, I want my extension to start after:


You could add your extension directly under the above processor in the web.config file. Though of course best practice is to add a new include file, making sure the new include file is rendered in the desired order:
 
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <pipelines>
      <httpRequestBegin>
        <processor patch:after="*[@type='Sitecore.Pipelines.HttpRequest.IgnoreList, Sitecore.Kernel']"
          type="MyExtensions.Pipelines.HttpRequest.Sleep, MyExtensions" />
      </httpRequestBegin>
    </pipelines>
  </sitecore>
</configuration>

... finally, load yourDomain/Sitecore/admin/showconfig.aspx to verify your extension is rendered the right place:

Sitecore Pipeline Profiler

In Sitecore version 7, Sitecore introduced a new profiling tool, the Pipeline Profiler. From the Pipeline Profiler tool, you will be able to monitor performance and utilizations of all the Sitecore pipelines used by the Sitecore solution (the Sitecore client and the website). The Pipeline Profiler tool listing the profiling data for each of the pipeline processors. 

Getting this data, you will be able to pinpoint the processors spending most of the time and improve performance by optimizing those specific processors.

You access the Pipeline Profiler tool from yourDomain/sitecore/admin/pipelines.aspx (the same location as the stats.aspx, showconfig.aspx, dbbrowser.aspx etc). However, Sitecore disables the Pipeline Profiler tool by default:


To enable the tool, the only thing you need to do, is to enable the Sitecore.PipelineProfiling.config.disable (by removing the “.disable”) located at /App_Config/Include, and reload the Pipeline Profiler tool:



In Sitecore 8, the Sitecore.PipelineProfiling.config file contains only two settings, the “Pipelines.Profiling.Enable” and the “Pipelines.Profiling.MEasureCpuTime” respectively:

  
        <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/">
            <sitecore>
                    <settings>
                    <!--  PIPELINE PROFILING ENABLED
                             Specifies whether or not pipeline profiling is enabled. When it is enabled, a profiling snapshot is available 
                             at /sitecore/admin/pipelines.aspx.
                             Default value: true
                    -->
                    <setting name="Pipelines.Profiling.Enabled" set:value="true" />

                    <!--  PIPELINE PROFILING MEASURE CPU TIME
                            Specifies whether or not the pipeline profiler measures CPU usage. Measuring CPU usage adds a performance overhead
                            to the pipeline but provides additional information about the behavior of the processors.
                            Default value: false
                    -->
                    <setting name="Pipelines.Profiling.MeasureCpuTime" set:value="false" />
                </settings>


Notice, the value of “Pipelines.Profiling.MeasureCpuTime” is false by default. Setting it to true, the Pipeline Profiling tool will measure the CPU usage as well:


If we add a new custom processor to the httpRequestPipeline etc. the new processor will be measured as well (In this case, the only thing the processor does, is sleep in 5 sec.)


Notice that Sitecore highlights the three processor of each pipeline taking most of the resource (indicated by the image number to the left of the processors).
The performance and utilization details declaration are at the bottom of the Pipeline Profiler tool:

Sitecore ECM - Remove App Center Warnings

Did you not purchased the Spam Detecter and/or the Email Preview service from the Sitecore App Center? ECM will constantly warn you with red massive ribbons as showed below. It is really a disturbing warning, when you work with the ECM (version 2.x).




If you want to remove the warnings, you simple have to delete the two following items (remember to back up the two items):

  • /sitecore/system/Modules/SPEAK/EmailCampaign/TaskPages/AdHockTaskPage/Review/EmailPreview
  • /sitecore/system/Modules/SPEAK/EmailCampaign/TaskPages/AdHockTaskPage/Review/SpamCheck

Here u go, After removing the two items, ECM no longer shows the warnings.

Disabling WebDAV

Do you use WebDAV when uploading media files to Sitecore? If not, why not disable WebDAV and reduce the number of log files and errors in the system log file? At least consider disabling it at your Content Delivery servers. It is easy and requires only five step and it is all done in the web.config file.

Step 1
Locate and remove (or out comment) the appender section named “WebDAVLogFileAppender” in within the setting (This section defines the location of the log files).
 
<appender name="LogFileAppender" type="log4net.Appender.SitecoreLogFileAppender, Sitecore.Logging">
      <file value="$(dataFolder)/logs/log.{date}.txt" />
      <appendToFile value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%4t %d{ABSOLUTE} %-5p %m%n" />
      </layout>
    </appender>
<!--    <appender name="WebDAVLogFileAppender" type="log4net.Appender.SitecoreLogFileAppender, Sitecore.Logging">
      <file value="$(dataFolder)/logs/WebDAV.log.{date}.txt" />
      <appendToFile value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%4t %d{ABSOLUTE} %-5p %m%n" />
      </layout>
    </appender> -->
    <appender name="SearchLogFileAppender" type="log4net.Appender.SitecoreLogFileAppender, Sitecore.Logging">
      <file value="$(dataFolder)/logs/Search.log.{date}.txt" />
      <appendToFile value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%4t %d{ABSOLUTE} %-5p %m%n" />
      </layout>
    </appender>

Step 2
Locate the system.webServer section and remove (or out comment) setting the remove setting named “WebDAVModule”.
 
<system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
     <!-- <remove name="WebDAVModule" />-->
      <add type="Sitecore.Web.RewriteModule, Sitecore.Kernel" name="SitecoreRewriteModule" />
…
  </modules>

Step 3
At the handlers section of the system.webServer locate and remove (or comment out) the following three settings of WebDAV
 
    <handlers>
<!--      <add name="WebDAVRoot" path="*" verb="OPTIONS,PROPFIND" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" preCondition="classicMode,runtimeVersionv4.0,bitness32" />
      <add name="WebDAVRoot64" path="*" verb="OPTIONS,PROPFIND" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" preCondition="classicMode,runtimeVersionv4.0,bitness64" />
      <add verb="*" path="sitecore_webDAV.ashx" type="Sitecore.Resources.Media.WebDAVMediaRequestHandler, Sitecore.Kernel" name="Sitecore.WebDAVMediaRequestHandler" /> -->
…
</handlers>

Step 4
Locate the httpHandlers section at system.Web and remove (or comment out) the WebDAV setting.
 
<httpHandlers>
      <add verb="*" path="sitecore_webDAV.ashx" type="Sitecore.Resources.Media.WebDAVMediaRequestHandler, Sitecore.Kernel" />
      <add verb="*" path="sitecore_media.ashx" type="Sitecore.Resources.Media.MediaRequestHandler, Sitecore.Kernel" />

Step 5
When you have comment out all the web.config settings of WebDAV listed above, you can now disable the Sitecore.WebDAV.config file from App_Config/Include folder.

Cleanup strategy missing WebDAV, Search and Cragling

What about the cleanup strategy for WebDAV.log, Search.log and Crawling.log, Sitecore?


Whenever Sitecore version 7.X restarts, it creates four new log files. The naming and location of these log files are managed in the <log4net> setting in the web.config file. The first log file Sitecore creates is the system log file. This log file is named log.[yyyyMMdd].txt and is managed at the "LogFileAppender". The second log file is the WebDAV log file named WebDAV.log.[yyyyMMdd].txt handled by the "WebDAVLogFileAppender". The third handles the search indexing operations named Search.log.[yyyyMMdd].txt and fourth handles the logging for search query operations named Crawling.log.[yyyyMMdd].txt and are managed at the "SearchLogFileAppender" and "CrawlingLogFileAppender" respectively.

If Sitecore restarts more than once a day, the time of creation (HHmmss) will be added to the all subsequent log files for that specific day E.g. log.[yyyyMMdd].[HHmmss].txt.

The "Appender" section contains:
    
<appender name="LogFileAppender" type="log4net.Appender.SitecoreLogFileAppender, Sitecore.Logging">
    <file value="$(dataFolder)/logs/log.{date}.txt">
        <appendtofile value="true">
            <layout type="log4net.Layout.PatternLayout">
                <conversionpattern value="%4t %d{ABSOLUTE} %-5p %m%n" />
            </layout>
        </appendtofile>
    </file>
</appender>
<appender name="WebDAVLogFileAppender" type="log4net.Appender.SitecoreLogFileAppender, Sitecore.Logging">
    <file value="$(dataFolder)/logs/WebDAV.log.{date}.txt">
        <appendtofile value="true">
            <layout type="log4net.Layout.PatternLayout">
                <conversionpattern value="%4t %d{ABSOLUTE} %-5p %m%n" />
            </layout>
        </appendtofile>
    </file>
</appender>
<appender name="SearchLogFileAppender" type="log4net.Appender.SitecoreLogFileAppender, Sitecore.Logging">
    <file value="$(dataFolder)/logs/Search.log.{date}.txt">
        <appendtofile value="true">
            <layout type="log4net.Layout.PatternLayout">
                <conversionpattern value="%4t %d{ABSOLUTE} %-5p %m%n" />
            </layout>
        </appendtofile>
    </file>
</appender>
<appender name="CrawlingLogFileAppender" type="log4net.Appender.SitecoreLogFileAppender, Sitecore.Logging">
    <file value="$(dataFolder)/logs/Crawling.log.{date}.txt">
        <appendtofile value="true">
            <layout type="log4net.Layout.PatternLayout">
                <conversionpattern value="%4t %d{ABSOLUTE} %-5p %m%n" />
            </layout>
        </appendtofile>
    </file>
</appender>

If you compare the "appender" settings listed above with the "Sitecore.Tasks.CleanupAgent" placed at <sitecore> <scheduling> <agent> setting you will notice that the CleanupAgent does not contain any remove settings regarding the log files of WebDAV, Search or Crawling. Put in another way, by default Sitecore does not clean up this three log files, which results in a solution with an unmanageable number log files (If you take this into a Sitecore version 6.X, you get the same regarding the WebDAV log files).

It is easy to set up Sitecore to clean up the three additional log files. You could simply prefix "log.*.txt" with "*." at:
            
<remove folder="$(dataFolder)/logs" pattern="log.*.txt" maxcount="50" minage="30.00:00:00" />


Ending up with this:
            
<remove folder="$(dataFolder)/logs" pattern="*.log.*.txt" maxCount="50" minAge="30.00:00:00" />
In this case, the three additional log files will follow the same life cycle as the system log file. If you want specific life cycles for each of the log files you could add specific "remove" settings for each of the log files ending up with something like this:

<files hint="raw:AddCommand">
    <remove folder="$(dataFolder)/logs" pattern="log.*.txt" maxcount="50" minage="30.00:00:00" />
    <remove folder="$(dataFolder)/logs" pattern="WebDAV.log.*.txt" maxcount="20" minage="7.00:00:00" />
    <remove folder="$(dataFolder)/logs" pattern="Search.log.*.txt" maxcount="20" minage="7.00:00:00" />
    <remove folder="$(dataFolder)/logs" pattern="Crawling.log.*.txt" maxcount="20" minage="7.00:00:00" />
… 
</files>

In this case, Sitecore will store the system log file at least for 30 days, if the number of system log files does not exceed the number of 50, while Sitecore will only store the log files of WebDAV, Search and Crawling for seven days.

If you are not using WebDAV in your Sitecore solution, you can easily disable it. This is how you disable WebDAV.

CleanUpAgent and Log Files

Normally I have a checklist of different configurations, settings etc. I change, whenever I setup a new Sitecore solution. One of the items on the list is how long Sitecore saves the system log files. It is frustrating to investigate an error, if the system log file has been deleted.

Sitecore has an agent that handles the cleanup strategy, and by default, Sitecore deletes system log files when they are older than 7 days. It is easy to change and handled in the web.config. The cleanup strategy of the log files is managed by the Sitecore.Tasks.CleanupAgent placed at <sitecore><scheduling><agent> setting in the web.config file.


        
        
          
          
          
          
          
        
      

If you want Sitecore to store the system log files for E.g. the last 30 days, you should change the [minAge] from “7.00:00:00” attribute to “30.00:00:00”. Taking into account, the [maxCount] attribute by default is valued “20”, Sitecore will only store 20 of the system log files. Therefore, you should either change the [maxCount] to at least “30”, delete the attribute or add [rolling=”true”] to ignore the [maxCount] and [minCount] attribute.

It would look like these:
      

Disable SPEAK dialogs - Sitecore

Did you have trouble with Sitecore SPEAK dialogs in Sitecore? We had!

Because Sitecore SPEAK adds these dialogs by overriding the existing dialogs in Sitecore, you can easily disable the SPEAK dialogs and use the old standard dialogs instead.

Sitecore has added a new include file, managing whether Sitecore uses the SPEAK dialogs or the old classic dialogs. Among other sections, the include file contain sections concerning the dialogs of media item and links, respectively. The include file is named Sitecore.Speak.config (and is stored at /App_Config/Includes/ next to all the other include files). In the include file you can easily override/comment out the SPEAK dialogs, you do not want to use.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <overridexmlcontrols>
      <override with="/sitecore/client/applications/Dialogs/SelectMediaDialog" xmlcontrol="Sitecore.Shell.Applications.Media.MediaBrowser" />
    </overridexmlcontrols>
 
    <overridedialogs>
      <override dialogurl="/sitecore/shell/Applications/Dialogs/Internal%20link.aspx" with="/sitecore/client/applications/dialogs/InsertLinkViaTreeDialog" />
      <override dialogurl="/sitecore/shell/Applications/Dialogs/Mail%20link.aspx" with="/sitecore/client/applications/dialogs/InsertEmailDialog" />
      <override dialogurl="/sitecore/shell/Applications/Dialogs/Anchor%20link.aspx" with="/sitecore/client/applications/dialogs/InsertAnchorDialog" />
      <override dialogurl="/sitecore/shell/Applications/Item%20browser.aspx" with="/sitecore/client/applications/dialogs/InsertSitecoreItemViaTreeDialog" />
    </overridedialogs>
 
    ...
    ...
  </sitecore>
</configuration>