Monday, August 31, 2015

Sitecore logs - How to find errors and issues

Environment - Sitecore 8.0 rev. 150621

Hi all,

If you worked as a pure .NET developer and you moved to work with Sitecore you will get the same problems as I had few months back from now.

"How am I going debug this ???"
"Where are the errors ??"
"How can I find the errors on my site and any function ???"

Those are my questions when I start Sitecore. Since Sitecore is a product and it uses it's own dll files to perform it's internal tasks we can't debug the classes inside the Sitecore like we do in a pure .Net project. But Sitecore provide a way to take you out from these troubles. Sitecore log files.
You can find these log files on your data_folder/App_Data/Sitecore/logs

Sitecore uses Apache's log4net to create log files. You can have a read on log4net from here.

There are 3 types of log files

1. Standard log (log)
This is the most common log. This log will log errors, warnings, information, etc according to your settings.

            Verbose log
This logging feature is disabled by default. This feature is designed to provide search index configuration and provide more rich and more detailed version of the problem. You can enabled this feature by removing the '.example' from the 'Sitecore.ContentSearch.VerboseLogging.config.example' cofig files inside the {your_site_folder}/App_Config/Include

* Verbose Log should enable only on special scenarios and never run long period of time specially on production environments. Since verbose logger would creates an extremely large log file, it can cause to a performance issue.

2. Crawling log (Crawling.log)
Track information about indexing operations. (I'll talk about Sitecore Indexing in latter session)

Following shows an example of  a crawling log.

11704 13:22:13 INFO  [Index=social_messages_web] Initializing SitecoreItemCrawler. DB:web / Root:/sitecore/social/Messages
11704 13:22:13 INFO  [Index=sitecore_analytics_index] Initializing TimedIndexStrategy with interval '00:01:00'.
11704 13:22:13 INFO  [Index=sitecore_core_index] Initializing IntervalAsynchronousUpdateStrategy with interval '00:01:00'.
11704 13:22:13 INFO  [Index=sitecore_master_index] Initializing SynchronousStrategy.
11704 13:22:13 INFO  [Index=sitecore_web_index] Initializing OnPublishEndAsynchronousStrategy.
11704 13:22:13 FATAL [Index=sitecore_web_index] Initialization of OnPublishEndAsynchronousStrategy failed because event queue is not enabled.

By default the Crawling log is set to output logs on 'INFO' level.

3. Search log (Search.log)
Shows queries that were generated and run.

Following shows an example for a search log.

3724 13:47:58 INFO  ExecuteQueryAgainstLucene (sitecore_analytics_index): type:contact - Filter :
3724 13:47:58 INFO  ExecuteQueryAgainstLucene (sitecore_analytics_index): type:contact - Filter :
3724 13:47:58 INFO  ExecuteQueryAgainstLucene (sitecore_analytics_index): +contact.contactid:a2a2d13f8603400d864c7914aadd593d +type:visit - Filter :

To get the full level details of the content search you have to enable the 'Sitecore.ContentSearch.config' and change the logging level to 'DEBUG'.

You can find all the configurations related to these log files in the <log4net> section of the web.config file.
According to the requirement you can increase or decrease the level of the log. The following provides the logging levels minimum to high.

  1. OFF - nothing gets logged 
  2. FATAL
  3. ERROR
  4. WARN
  5. INFO
  6. DEBUG
  7. ALL - everything gets logged

* Your log levels can be changed when you enabled the Verbose logging.

Sitecore will create logs for each day. If you want fresh logs on a day, you can restart the site from Microsoft IIS Manager. Then Sitecore will create logs with date and number. (ex- log.20150828.132211.txt)

* If you are still like to see the .Net errors on the page when you are testing you can turn off the custom errors on the web.config file.

Change <customErrors mode="On"  /> to <customErrors mode="Off"  />

No comments:

Post a Comment