Pages

Top 5 posts

Monday, August 30, 2010

Sitecore Media Library Policeman. Free shared source module.


Greetings! It is my pleasure to announce the very first module for Sitecore CMS I developed in collaboration with Ivan Sharamok finally made it to Shared Source Library.

The idea behind the module belongs to a customer who was willing to take full control over the Sitecore Media Library in their multi site solution. Managing more than 15 sites on one instance, it is important to restrict permissions on different areas of the content tree, as well as /media library branch.

I’ve seen too many situations in my practice where this important aspect has been neglected and hundreds of media files ended up in the root of media library, causing all sorts of performance and compatibility issues.

This module will hopefully provide a good starting point for what you can do in terms of policing your Media Library.

Instead of writing a bunch of boring docs, I decided to put a boring video on YouTube.

Enjoy!

Friday, August 06, 2010

Sitecore Logging Part 4. Integration with Log4Net Dashboard.


In my older posts I was showing how to teach Sitecore CMS to log events into a SQL Server database, today it is time to reveal the last part of this blog series.

Having everything in SQL is great, and it already enables you run queries, but wouldn’t it better to have some sort of a visual dashboard showing you all new events, highlighted by severity and type, and also let you filter those?
I liked that idea and decided to try out how this Log4Net Dashboard component by FaktNet AS can accomplish this.

The download is free for development workstations, which is awesome.
The installation was quite simple, it is just an ASP.NET application, really. I configured it as a separate site in IIS to simplify things.
The configuration was quite easy too:

1. Configure the LocalSql datasource where you need to specify the connection string to your SQL Server database with the Log table:

<datasource name="LocalSql"
Description="Log4Net logging events stored in the SQL Server database on the local machine">
 <provider type="L4NDashSqlServerProvider.SqlServerProvider" 
assembly="L4NDashSqlServerProvider, Version=2.4, Culture=neutral"/>
  <predefinedsearchfilter value="Filters\DefaultSearchFilters.xml"/>
   <providersettings>
     <connectionstring value="user id=sa;password=*;Data Source=(local);Database=db"/>
       <TableName value="Log" />
            <!-- 
               Defines timeout (in seconds) for sql commands, if the log table is huge or the database server
               is "jammed" you may need to increase this 
                -->
            <SqlCommandTimeout value="60"/>
            <!--Max number of rows to retrieve for the log rows panel-->
            <MaxNoOfRowsToRetrieve value="1000"/>
   </providersettings>
   ...

2. Verify that the “TableName” and column reference correspond to your table in SQL:

<NameMapping TableName="Log"
             IdColumn="Id"
             DateColumn="Date"
             LevelColumn="Level"
             ThreadColumn="Thread"
             LoggerColumn="Logger"
             MessageColumn="Message"
             ExceptionColumn="Exception" />

3. If you extended the ADONetAppender as I showed previously, define the following custom columns:

<customcolumn name="SCUser">
   <label value="User Name" />
   <rowstabledisplay value= "yes" />
   <rowsdetaildisplay value= "yes" />
   <filter value="yes" />
</customcolumn>
<customcolumn name="SCItemId">
   <label value="Item Id" />
   <rowstabledisplay value= "yes" />
   <rowsdetaildisplay value= "yes" />
   <filter value="yes" />
</customcolumn>
<customcolumn name="RawUrl">
   <label value="Raw Url" />
   <rowstabledisplay value= "yes" />
   <rowsdetaildisplay value= "yes" />
   <filter value="yes" />
</customcolumn>

Now you can run the Log4Net Dashboard application, but before you can view any of the Sitecore logs from the database, you need to make sure to select “LocalSql” as your default datasource:
image 
That’s all – refresh the application and enjoy nice visualization of how your app is doing:
 image 

Now that we have everything running smoothly, let’s add another piece. Let’s bring this application to Sitecore desktop. The easiest way to do it is to change the configuration of the default Sitecore Logging application. Specifically:

1. Login to Desktop –> core database.
2. Navigate to /sitecore/content/Applications/Reports/LogViewer:
3. Paste the URL of your Log4Net Dashboard application into the “Application” field:
image
Now refresh the browser and open Log Viewer application:
image

Here you go – refreshed Log Viewer available from Sitecore desktop interface:
image

In production, I’d disabled anonymous access to this application and probably added some IP restrictions too, so this app can safely be access from outside.
Of course for running in production, you will need to get the license from the Log4Net Dashboard vendor.

I suggest you try it and check out this video to see more of the specific capabilities of this tool:

That’s all, folks!