Surendra Sharma

Surendra Sharma

Search This Blog

Showing posts with label Tech Tips. Show all posts
Showing posts with label Tech Tips. Show all posts

Tuesday, October 29, 2019

Multilist in Sitecore JSS App

For the list data, Sitecore JSS offering "ContentList" as a field datatype. When you deploy it in Sitecore, it converts into "Treelist".

But what to do if you need "Multilist" instead of Treelist at Sitecore side?

Solution:
 

You have to specify "MultiList" as a string type when you define the Sitecore field definition for the component as

name: 'content'type: CommonFieldTypes.RichText },
name: 'articleList'type: 'MultiList'},

As you can notice here I defined "ArticleList" field as a "MultiList" datatype.

You can also set the datasource or query with this Multilist field definition as


name: 'articleList'type: 'MultiList'source: `query:./Articles/*`, },

Here I have set the datasource as a child folder "articles" of current Sitecore context item.

I hope this quick tip help you in Sitecore JSS App development.

Wednesday, April 5, 2017

How to recycle application pool automatically in IIS


What will you do if you get a call on holiday or weekend that your website hosted server is consuming 95% CPU utilization due to IIS worker process and within a few minutes, your server is going to crash and your website will not be accessible?


You have to access the server and recycle your app pool, right?

Can we provide some automated solution for this?

Yes, fortunately IIS can take care of this situation.

Let's say if CPU utilization reached to 92% and it remains at 92% or more for next 3 minute then we want IIS should recycle application pool automatically.

Follow below steps to achieve this.

  • Open IIS. 
  • Right click on your website application pool and select “Advance Setting…
  • Locate CPU section 
  • Put Limit (percent) as 92% 
  • Set Limit Action at KillW3wp 
  • Set Limit Interval (minutes) at 3 
  • Click Ok

That's it.

Here is a screenshot for quick understanding

App Pool Recycle automatically
App Pool Recycle automatically

Now no manual intervention is required. You can enjoy your weekend. But remember this is not a a solution, this is just a work around for the problem. You should find the root cause of the problem.

Tuesday, March 28, 2017

How to change log level of Sitecore log files



On one of our Sitecore hosted server, log files sizes are growing rapidly. We are fine with few MB, but some of our search logs are growing more than 300 MB as shown below

Logs file in Data\logs folder
Logs file in Data\logs folder

Instead of logging everything, we want to log only error messages to reduce the file sizes.

How to achieve it?

Open your Sitecore web.config file.

Find “<log4net>” and locate logger section for “SearchLogFileAppender

Change its level from INFO to ERROR as

    <logger name="Sitecore.Diagnostics.Search" additivity="false">
      <level value="ERROR"/>
      <appender-ref ref="SearchLogFileAppender"/>
    </logger>

Now your search log should only record searching related errors.

In same way, you can also change log level for Crawling, WebDAV, publishing and Sitecore logs files.

I hope you like this Sitecore trick. Stay tuned for more Sitecore related articles.

Till that happy Sitecoring :)

Please leave your comments or share this trick if it’s useful for you.

Friday, March 24, 2017

Exception in UrlAgent url: /sitecore/service/keepalive.aspx

We notice below error in our project log files on CD server as 
 
ManagedPoolThread #15 00:23:21 INFO  Job started: Sitecore.Tasks.UrlAgent
ManagedPoolThread #15 00:23:21 INFO  Scheduling.UrlAgent started. Url: http://www.sitecorelessons.com/sitecore/service/keepalive.aspx
ManagedPoolThread #15 00:23:21 ERROR Exception in UrlAgent (url: /sitecore/service/keepalive.aspx)
Exception: System.Net.WebException
Message: The remote server returned an error: (401) Unauthorized.
Source: System
   at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
   at System.Net.WebClient.DownloadData(Uri address)
   at Sitecore.Web.WebUtil.ExecuteWebPage(String url, NameValueCollection headers)
   at Sitecore.Tasks.UrlAgent.Run()
ManagedPoolThread #15 00:23:21 INFO  Job ended: Sitecore.Tasks.UrlAgent (units processed: )

What’s the root cause and how to fix this error?

Solution:

Problem was that Anonymous access permission was denied on server for Sitecore folder.

It’s a good practice to remove access permissions from Sitecore folder on CD server.

However to fix this issue either we have to provide access permission to Service folder or keep its files on some other location and then change config files entries according to that new path.

We can provide access permission to service folder as

  • Open IIS
  • Navigate to Service folder of your website and open Authentication as
 
Folder Authentication
Folder Authentication

  • Select Anonymous Authentication and Enable its status as
 
Enable Anonymous Authentication
Enable Anonymous Authentication

That's it.

We didn’t find any new error in log files after allowing permission to Service folder.

After fixing this, we are now receiving proper log as

ManagedPoolThread #6 02:12:23 INFO  Job started: Sitecore.Tasks.UrlAgent
ManagedPoolThread #6 02:12:23 INFO  Scheduling.UrlAgent started. Url: http://www.sitecorelessons.com/sitecore/service/keepalive.aspx
ManagedPoolThread #6 02:12:23 INFO  Scheduling.UrlAgent done (received: 561 bytes)
ManagedPoolThread #6 02:12:23 INFO  Job ended: Sitecore.Tasks.UrlAgent (units processed: )

I hope you like this Sitecore tip. Stay tuned for more Sitecore related articles.

Till that happy Sitecoring :)

Please leave your comments or share this script if it’s useful for you.