[id='enable_statistics']
= Enabling {brandname} Statistics
{brandname} lets you enable statistics for Cache Managers and specific cache
instances.

[NOTE]
====
{brandname} servers provide default `infinispan.xml` configuration files that
enable statistics for Cache Managers. If you use the default {brandname} server
configuration, you only need to enable statistics when you configure caches.
====

.Procedure

* Enable statistics declaratively or programmatically.

.Declaratively

[source,xml,options="nowrap",subs=attributes+]
----
<cache-container statistics="true"> <1>
  <local-cache name="mycache" statistics="true"/> <2>
</cache-container>
----

<1> collects statistics about the Cache Manager.
<2> collects statistics about the named cache.

.Programmatically

[source,java]
----
GlobalConfiguration globalConfig = new GlobalConfigurationBuilder()
  .cacheContainer().statistics(true) <1>
  .build();

 ...

Configuration config = new ConfigurationBuilder()
  .statistics().enable() <2>
  .build();
----

<1> collects statistics about the Cache Manager.
<2> collects statistics about the named cache.

[NOTE]
====
Enabling statistics for Cache Managers does not globally enable statistics for
caches. This configuration only collects statistics for the Cache Manager.
====
