1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Custom logging

Custom logging

6 posts, 2 answered
  1. Lucas
    Lucas avatar
    65 posts
    Registered:
    22 Mar 2010
    06 Apr 2010
    Link to this post
    Is there an easy way to replace Sitefinity's Logging system by a custom one (we're logging our events in a central database for all our websites) ?

    Additionnaly, is it possible to catch some additional events, such as when a user logs in, or tries to access a restricted page ?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    06 Apr 2010
    Link to this post
    Hi Lucas,

    Sitefinity uses ASP.NET Login control. You could replace it inSitefinity/Login.aspx page and add your custom logic in the code behind.

    You could handle when an user has been logged in in LoggedIn event of the Login control. To determine whether someone is trying to access restricted page you could create a custom HttpModule or HttpHandler and check whether the Request is Authenticated or not. If the request is authenticated you could get the principal and its permissions over the page. From the requested url you could get the ICmsPage object and pass it to CmsManager. Then you could see whether the anonymous access is allowed or denied. To check the page permissions you have to create ISecured object and call GetPermission method.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
    Answered
  3. Lucas
    Lucas avatar
    65 posts
    Registered:
    22 Mar 2010
    06 Apr 2010
    Link to this post
    Thanks a lot for your quick reply (I didn't see the codebehind for login.aspx was available).

    What about adding logging (we're using log4net)? I'm guessing I need to add new providers to the "healthMonitoring" section, but where does Sitefinity decide which one to use?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    06 Apr 2010
    Link to this post
    Hello Lucas,

    The default provider is

    <add name="Simple Web Event Provider" type="Telerik.Utilities.TextFileWebEventProvider,Telerik.Framework" logFileName="~/App_Data/sitefinity.log"/>

    If you comment it the application will stop logging errors into sitefinity.log file, but you will need a new provider that inherits from TextFileWebEventProvider. Anyway you could catch each exception in Global.asax, Application_Error and implement your custom logic.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. Lucas
    Lucas avatar
    65 posts
    Registered:
    22 Mar 2010
    06 Apr 2010
    Link to this post
    Ok thanks.

    Is the provider's name used by sitefinity or can I choose any name ?
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    06 Apr 2010
    Link to this post
    Hello Lucas,

    The name does not matter. The important part is the host you will set. The provider name should be set for the health monitoring rules

    <rules>
                    <add name="SitefinityEventHandler" eventName="Simple Web Request Event" provider="Simple Web Event Provider" minInterval="00:00:00" minInstances="1" maxLimit="Infinite"/>
                    <add name="SitefinityErrorHandler" eventName="All Errors" provider="Simple Web Event Provider" minInterval="00:00:00" minInstances="1" maxLimit="Infinite"/>
                    <add name="SitefinityCodeBenchmarkHandler" eventName="Code Benchmark Event" provider="Code Benchmark Provider" minInterval="00:00:00" minInstances="1" maxLimit="Infinite"/>
                </rules>

    All the best,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
    Answered
Register for webinar
6 posts, 2 answered