public void AddUrlLog(int PortalId, int UserId, string Referrer, string URL, string OriginalURL, string RedirectURL, string UserAgent, string UserHostAddress, string UserHostName, int TabId, int Statuscode, int UrlLogBuffer,
                               string UrlLogStorage)
        {
            var objSecurity = new PortalSecurity();
            try
            {
                if (Host.PerformanceSetting == Globals.PerformanceSettings.NoCaching)
                {
                    UrlLogBuffer = 1;
                }
                switch (UrlLogBuffer)
                {
                    case 0: //logging disabled
                        break;
                    case 1: //no buffering
                        switch (UrlLogStorage)
                        {
                            case "D": //database
                                DataProvider.Instance().ExecuteNonQuery(ModuleQualifier + "AddUrlLog",
                                                                   DateTime.Now,
                                                                   PortalId,
                                                                   UserId,
                                                                   objSecurity.InputFilter(Referrer, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup),
                                                                   objSecurity.InputFilter(URL, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup),
                                                                   objSecurity.InputFilter(OriginalURL, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup),
                                                                   objSecurity.InputFilter(RedirectURL, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup),
                                                                   objSecurity.InputFilter(UserAgent, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup),
                                                                   objSecurity.InputFilter(UserHostAddress, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup),
                                                                   objSecurity.InputFilter(UserHostName, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup),
                                                                   TabId, Statuscode);
                                break;
                            case "F": //file system
                                W3CExtendedLog(DateTime.Now,
                                               PortalId,
                                               UserId,
                                               objSecurity.InputFilter(Referrer, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup),
                                               objSecurity.InputFilter(URL, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup),
                                               objSecurity.InputFilter(OriginalURL, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup),
                                               objSecurity.InputFilter(RedirectURL, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup),
                                               objSecurity.InputFilter(UserAgent, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup),
                                               objSecurity.InputFilter(UserHostAddress, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup),
                                               objSecurity.InputFilter(UserHostName, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup),
                                               TabId, Statuscode);
                                break;
                        }
                        break;
                    default: //buffered logging
                        string key = "UrlLog" + PortalId;
                        var arrUrlLog = (ArrayList) DataCache.GetCache(key);

                        //get buffered site log records from the cache
                        if (arrUrlLog == null)
                        {
                            arrUrlLog = new ArrayList();
                            DataCache.SetCache(key, arrUrlLog);
                        }

                        //create new UrlLog object
                        var objUrlLog = new UrlLogInfo();
                        objUrlLog.DateTime = DateTime.Now;
                        objUrlLog.PortalId = PortalId;
                        objUrlLog.UserId = UserId;
                        objUrlLog.Referrer = objSecurity.InputFilter(Referrer, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup);
                        objUrlLog.URL = objSecurity.InputFilter(URL, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup);
                        objUrlLog.OriginalURL = objSecurity.InputFilter(OriginalURL, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup);
                        objUrlLog.RedirectURL = objSecurity.InputFilter(RedirectURL, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup);
                        objUrlLog.UserAgent = objSecurity.InputFilter(UserAgent, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup);
                        objUrlLog.UserHostAddress = objSecurity.InputFilter(UserHostAddress, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup);
                        objUrlLog.UserHostName = objSecurity.InputFilter(UserHostName, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup);
                        objUrlLog.TabId = TabId;
                        objUrlLog.StatusCode = Statuscode;

                        //add UrlLog object to cache
                        arrUrlLog.Add(objUrlLog);

                        if (arrUrlLog.Count >= UrlLogBuffer)
                        {
                            //create the buffered UrlLog object
                            var objBufferedUrlLog = new BufferedUrlLog();
                            objBufferedUrlLog.UrlLogStorage = UrlLogStorage;
                            objBufferedUrlLog.UrlLog = arrUrlLog;

                            //clear the current UrlLogs from the cache
                            DataCache.RemoveCache(key);

                            //process buffered UrlLogs on a background thread
                            var objThread = new Thread(objBufferedUrlLog.AddUrlLog);
                            objThread.Start();
                        }
                        break;
                }
            }
            catch (Exception exc)
            {
                DotNetNuke.Instrumentation.DnnLog.Error(exc);

            }
        }