How to disable Sitecore Analytics entirely - sitecore

We are experiencing cpu problems on our production servers. After profiling with the jetbrains cpu profiler, we have noticed that some functions in the assembly Sitecore.Analytics were executed.
This is somewhat strange because we have disabled all analytics related configuration in de config files.
After looking into the /sitecore/admin/showconfig.aspx we noticed that there are still a lot of Sitecore.Analytics related configurations in this config while these are deactivated in our config files.
For example
In the file /App_Config/Include/EventHandlers.config the configuration looks like this:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<events timingLevel="custom">
</events>
</sitecore>
</configuration>
When looking into the showconfig.aspx it looks something like this:
<events timingLevel="custom">
<event name="forms:save"/>
<event name="item:saved">
<handler type="Sitecore.Analytics.Data.Items.ItemEventHandler, Sitecore.Analytics" method="OnItemSaved"/>
<handler type="Sitecore.Analytics.Automation.Data.Items.ItemEventHandler, Sitecore.Automation.MarketingAutomation" method="OnAutomationStateChanged"/>
</event>
<event name="item:deleted">
<handler type="Sitecore.Analytics.Automation.Data.Items.ItemEventHandler, Sitecore.Automation.MarketingAutomation" method="OnAutomationStateChanged"/>
</event>
<event name="media:request">
<handler type="Sitecore.Analytics.Media.MediaRequestEventHandler, Sitecore.Analytics" method="OnMediaRequest"/>
</event>
</events>
Does anyone has an idea why these are still returning in the showconfig.aspx?
Is there a way to fully delete/disable the sitecore analytics module?

Yes. Rename the 3 configuration files for Sitecore.Analytics in your /App_Config/Include directory to something other than *.config
The 3 files are:
Sitecore.Analytics.config
Sitecore.Analytics.ExcludeRobots.config
Sitecore.Analytics.RobotDetection.config
(could vary a little bit by version, but they all start with Sitecore.Analytics).
Rename them to something like:
Sitecore.Analytics.config.disabled
Sitecore.Analytics.ExcludeRobots.config.disabled
Sitecore.Analytics.RobotDetection.config.disabled

(could vary a little bit by version, but they all start with Sitecore.Analytics).
Until sitecore version 72, there are only 3 files with Sitecore.Analytics prefix. In version 75, there are 17 and in version 8 there are 20 config files with Sitecore.Analytics prefix.
I used to confirm with sitecore support that you can change the setting of Analytics.Enabled in Sitecore.Analytics.config will disable Analytics
<setting name="Analytics.Enabled" value="false" />
Or only rename one file Sitecore.Analytics.config which contain this setting.

Did you try to User WFFM ?
There also analytics part:
Sitecore.WFFM.Analytics.config
and disabling it causes this fault:
22992 14:49:10 WARN Value cannot be null. Parameter name: owner
Exception: System.ArgumentNullException Message: Value cannot be null.
Parameter name: owner Source: Sitecore.Kernel at
Sitecore.Diagnostics.Assert.ArgumentNotNull(Object argument, String
argumentName) at Sitecore.Diagnostics.Log.Warn(String message,
Object owner) at Sitecore.WFFM.Core.Extensions.Warn.IsNull(Object
obj, String name) at
Sitecore.WFFM.Analytics.AnalyticsTracker.get_SessionId() at
Sitecore.Form.Core.FormDataHandler.ExecuteSaveActions(ID formId,
ControlResult[] fields, ActionDefinition[] actions) at
Sitecore.Form.Core.FormDataHandler.ProcessData(SimpleForm form,
ControlResult[] fields, ActionDefinition[] actions)
So it cannot be disabled.

Related

Custom unlock item button in sitecore experience editor

In Sitecore 8.1 update 2, how do we add a custom web edit button in experience editor to unlock items locked by other users using non admin authors in sitecore.
Getting below error while executing the command.
ERROR Error processing command url:/-/speak/request/v1/expeditor/ExperienceEditor.CustomUnlockItem error:System.InvalidOperationException: Could not retrieve request class for url:/-/speak/request/v1/expeditor/ExperienceEditor.CustomUnlockItem
at Sitecore.ExperienceEditor.Speak.Server.RequestHandler.Process(HttpContext context)
at Sitecore.ExperienceEditor.Speak.Server.RequestHandler.ProcessRequest(HttpContext context)
After correcting the config it was working fine, below is the correct configuration.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:x="http://www.sitecore.net/xmlconfig/">
<sitecore>
<commands>
<command name="webedit:customlock">
<patch:attribute name="type"><NameSpace>.CustomLock,<Assembly></patch:attribute>
</command>
</commands>
<sitecore.experienceeditor.speak.requests>
<request name="ExperienceEditor.CustomUnlockItem" type="<NameSpace>.CustomUnlockItem, <Assembly>" />
<request name="ExperienceEditor.GenerateFieldEditorUrl" type="<NameSpace>.GenerateFieldEditorUrl, <Assembly>" />
</sitecore.experienceeditor.speak.requests>
</sitecore>
</configuration>

java.lang.IllegalArgumentException:An invalid character [34] was present in the Cookie value

This is how my tomcat-users file looks like:
<tomcat-users>
<role rolename="admin"/>
<role rolename="analyst"/>
<role rolename="user"/>
<role rolename="kie-server"/>
<role rolename="developer"/>
<role rolename="manager"/>
<user username="w" password="w" roles="admin"/>
<user username="k" password="k" roles="kie-server"/>
<user username="u" password="u" roles="user,developer,analyst"/>
</tomcat-users>
After entering correct credentials in the KIE IDE WORKBENCH, I get the following exception:
java.lang.IllegalArgumentException: An invalid character [34] was present in the Cookie value
org.apache.tomcat.util.http.Rfc6265CookieProcessor.validateCookieValue(Rfc6265CookieProcessor.java:182)
org.apache.tomcat.util.http.Rfc6265CookieProcessor.generateHeader(Rfc6265CookieProcessor.java:115)
org.apache.catalina.connector.Response.generateCookieString(Response.java:1019)
org.apache.catalina.connector.Response.addCookie(Response.java:967)
org.apache.catalina.connector.ResponseFacade.addCookie(ResponseFacade.java:386)
org.uberfire.ext.security.server.SecurityIntegrationFilter.doFilter(SecurityIntegrationFilter.java:61)
CookieProcessor is a new configuration element, introduced in Tomcat 8.0.15.
The CookieProcessor element allows different cookie parsing configuration in each web application, or globally in the default conf/context.xml file.
According to official docs at Apache Tomcat 8 Configuration Reference
Version 8.0.47 :
The standard implementation of CookieProcessor is: org.apache.tomcat.util.http.LegacyCookieProcessor. Note that it is anticipated that this will change to org.apache.tomcat.util.http.Rfc6265CookieProcessor in a future Tomcat 8 release.
Later..
According to official docs at Apache Tomcat 8 Configuration Reference
Version 8.5.23
The standard implementation of CookieProcessor is org.apache.tomcat.util.http.Rfc6265CookieProcessor
To resolve this issue: add this line in conf/context.xml at location %CATALINA_HOME% (i.e. C:\apache-tomcat-8.5.20\conf\context.xml in my case):
<CookieProcessor className="org.apache.tomcat.util.http.LegacyCookieProcessor" />
This is how it looks like after adding:
<?xml version="1.0" encoding="UTF-8"?>
<Context reloadable="true">
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
<Transaction factory="bitronix.tm.BitronixUserTransactionObjectFactory"/>
<CookieProcessor className="org.apache.tomcat.util.http.LegacyCookieProcessor" />
</Context>

Log4Net to Azure WebJob

The question is specific to WebJobs. I've been thru the steps to configure logging to my Azure WebSite (sry...Azure AppService WebSite - sheese with the name changes already) and am now trying to iron everything out for WebJobs running beneath the same.
I'm logging to both a RollingFile and to the Ado.net appender - for sake of brevity pasting config only for the File - neither of the 2 work so gotta be a problem common at the core.
The sub-directory specified in the config exists but files are not being created within. The same configs are working for the host WebSite but WJs fail to log. Anywhere I can look for error messages or otherwise troubleshoot this?
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<appender name="FileAppender" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString" value="D:/home/site/wwwroot/App_Data/Logs/AccountMaintenance/log4net_%date{yyyyMMdd}.log" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="yyyyMMdd" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger %property – %message%newline" />
</layout>
</appender>
Shortly after posting this question I found a typo / syntax error in web.config file and my expected functionality returned.
Just for the record - here's a screenshot

Where is the Sitecore ASR database connection configured?

I'm trying to set up ASR up to email scheduled reports, but this is the error message I see in the log files.
Exception: ASR.Reports.Items.Exceptions.DatabaseNotFoundException
Message: Exception of type 'ASR.Reports.Items.Exceptions.DatabaseNotFoundException' was thrown.
Source: ASR.Reports
at ASR.Reports.Scanners.DatabaseScanner.get_Database()
at ASR.Reports.Items.QueryScanner.Scan()
at ASR.Interface.Report.Run(Object[] parameters)
at ASR.Commands.ScheduledExecution.runReport(Item item, Boolean force)
at ASR.Commands.ScheduledExecution.<>c__DisplayClass4.b__1(Item i)
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at ASR.Commands.ScheduledExecution.EmailReports(Item[] itemarray, CommandItem commandItem, ScheduleItem scheduleItem)
This doesn't make much sense since I'm able to generate reports through the admin interface.
In my ASR config
<setting name="ASR.ConfigurationDatabase" value="master"/>
In my Sitecore Analytics file
<scheduling>
<agent type="Sitecore.Analytics.Tasks.EmailReportsTask, Sitecore.Analytics" method="Run" interval="1:00:00">
DatabaseName>master
In my connection strings config, (which I know works because everything else is working)
<add name="master" connectionString="..." ... />
What am I missing?
ASR will use the ContentDatabase. When you run the report manually, you're running in the context of the "shell" site and it will default to master. When run as a scheduled task, the site will be "scheduler" which has no content database defined by default.
Try adding the following to a config file:
<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<sites>
<site name="scheduler">
<patch:attribute name="content">master</patch:attribute>
</site>
</sitecore>
</configuration>
Openly wondering if this is an issue to address back with the ASR module.

Log4Net "Could not find schema information" messages

I decided to use log4net as a logger for a new webservice project. Everything is working fine, but I get a lot of messages like the one below, for every log4net tag I am using in my web.config:
Could not find schema information for
the element 'log4net'...
Below are the relevant parts of my web.config:
<configSections>
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:\log.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="100KB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level: %message%newline" />
</layout>
</appender>
<logger name="TIMServerLog">
<level value="DEBUG" />
<appender-ref ref="RollingFileAppender" />
</logger>
</log4net>
Solved:
Copy every log4net specific tag to a separate xml-file. Make sure to use .xml as file extension.
Add the following line to AssemblyInfo.cs:
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "xmlFile.xml", Watch = true)]
nemo added:
Just a word of warning to anyone
follow the advice of the answers in
this thread. There is a possible
security risk by having the log4net
configuration in an xml off the root
of the web service, as it will be
accessible to anyone by default. Just
be advised if your configuration
contains sensitive data, you may want
to put it else where.
#wcm: I tried using a separate file. I added the following line to AssemblyInfo.cs
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]
and put everything dealing with log4net in that file, but I still get the same messages.
You can bind in a schema to the log4net element. There are a few floating around, most do not fully provide for the various options available. I created the following xsd to provide as much verification as possible:
http://csharptest.net/downloads/schema/log4net.xsd
You can bind it into the xml easily by modifying the log4net element:
<log4net
xsi:noNamespaceSchemaLocation="http://csharptest.net/downloads/schema/log4net.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
I had a different take, and needed the following syntax:
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.xml", Watch = true)]
which differs from xsl's last post, but made a difference for me. Check out this blog post, it helped me out.
Just a word of warning to anyone follow the advice of the answers in this thread. There is a possible security risk by having the log4net configuration in an xml off the root of the web service, as it will be accessible to anyone by default. Just be advised if your configuration contains sensitive data, you may want to put it else where.
I believe you are seeing the message because Visual Studio doesn't know how to validate the log4net section of the config file. You should be able to fix this by copying the log4net XSD into C:\Program Files\Microsoft Visual Studio 8\XML\Schemas (or wherever your Visual Studio is installed). As an added bonus you should now get intellisense support for log4net
In Roger's answer, where he provided a schema, this worked very well for me except where a commenter mentioned
This XSD is complaining about the use of custom appenders. It only allows for an appender from the default set (defined as an enum) instead of simply making this a string field
I modified the original schema which had a xs:simpletype named log4netAppenderTypes and removed the enumerations. I instead restricted it to a basic .NET typing pattern (I say basic because it just supports typename only, or typename, assembly -- however someone can extend it.
Simply replace the log4netAppenderTypes definition with the following in the XSD:
<xs:simpleType name="log4netAppenderTypes">
<xs:restriction base="xs:string">
<xs:pattern value="[A-Za-z_]\w*(\.[A-Za-z_]\w*)+(\s*,\s*[A-Za-z_]\w*(\.[A-Za-z_]\w*)+)?"/>
</xs:restriction>
</xs:simpleType>
I'm passing this back on to the original author if he wants to include it in his official version. Until then you'd have to download and modify the xsd and reference it in a relative manner, for example:
<log4net
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../Dependencies/log4net/log4net.xsd">
<!-- ... -->
</log4net>
Actually you don't need to stick to the .xml extension. You can specify any other extension in the ConfigFileExtension attribute:
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", ConfigFileExtension=".config", Watch = true)]
#steve_mtl: Changing the file extensions from .config to .xml solved the problem. Thank you.
#Wheelie: I couldn't try your suggestion, because I needed a solution which works with an unmodified Visual Studio installation.
To sum it up, here is how to solve the problem:
Copy every log4net specific tag to a separate xml-file. Make sure to use .xml as file extension.
Add the following line to AssemblyInfo.cs:
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "xmlFile.xml", Watch = true)]
For VS2008 just add the log4net.xsd file to your project; VS looks in the project folder as well as the installation directory that Wheelie mentioned.
Also, using a .config extension instead of .xml avoids the security issue since IIS doesn't serve *.config files by default.
Have you tried using a separate log4net.config file?
I got a test asp project to build by puting the xsd file in the visual studio schemas folder as described above (for me it is C:\Program Files\Microsoft Visual Studio 8\XML\Schemas) and then making my web.config look like this:
<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
<configSections>
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<appSettings>
</appSettings>
<connectionStrings>
</connectionStrings>
<system.web>
<trace enabled="true" pageOutput="true" />
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true" />
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows" />
<customErrors mode="Off"/>
<!--
<customErrors mode="Off"/>
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="On" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
</system.web>
<log4net xsi:noNamespaceSchemaLocation="http://csharptest.net/downloads/schema/log4net.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<appender name="LogFileAppender" type="log4net.Appender.FileAppender">
<!-- Please make shure the ..\\Logs directory exists! -->
<param name="File" value="Logs\\Log4Net.log"/>
<!--<param name="AppendToFile" value="true"/>-->
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c %m%n"/>
</layout>
</appender>
<appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">
<to value="" />
<from value="" />
<subject value="" />
<smtpHost value="" />
<bufferSize value="512" />
<lossy value="true" />
<evaluator type="log4net.Core.LevelEvaluator">
<threshold value="WARN"/>
</evaluator>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%newline%date [%thread] %-5level %logger [%property] - %message%newline%newline%newline" />
</layout>
</appender>
<logger name="File">
<level value="ALL" />
<appender-ref ref="LogFileAppender" />
</logger>
<logger name="EmailLog">
<level value="ALL" />
<appender-ref ref="SmtpAppender" />
</logger>
</log4net>
</configuration>
Without modifying your Visual Studio installation, and to take into account proper versioning/etc. amongst the rest of your team, add the .xsd file to your solution (as a 'Solution Item'), or if you only want it for a particular project, just embed it there.
I noticed it a bit late, but if you look into the examples log4net furnishes you can see them put all of the configuration data into an app.config, with one difference, the registration of configsection:
<!-- Register a section handler for the log4net section -->
<configSections>
<section name="log4net" type="System.Configuration.IgnoreSectionHandler" />
</configSections>
Could the definition it as type "System.Configuration.IgnoreSectionHandler" be the reason Visual Studio does not show any warning/error messages on the log4net stuff?
I followed Kit's answer https://stackoverflow.com/a/11780781/6139051 and it didn't worked for AppenderType values like "log4net.Appender.TraceAppender, log4net". The log4net.dll assembly has the AssemblyTitle of "log4net", i.e. the assembly name does not have a dot inside, that was why the regex in Kit's answer didn't work. I has to add the question mark after the third parenthetical group in the regexp, and after that it worked flawlessly.
The modified regex looks like the following:
<xs:pattern value="[A-Za-z_]\w*(\.[A-Za-z_]\w*)+(\s*,\s*[A-Za-z_]\w*(\.[A-Za-z_]\w*)?+)?"/>