[id='enable_statistics-{context}']
= Enabling {brandname} Statistics
{brandname} lets you enable statistics for Cache Managers and caches. However,
enabling statistics for a Cache Manager does not enable statistics for the
caches that it controls. You must explicitly enable statistics for your caches.

[NOTE]
====
{brandname} server enables statistics for Cache Managers by default.
====

.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> Enables statistics for the Cache Manager.
<2> Enables statistics for the named cache.

.Programmatically

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

 ...

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

<1> Enables statistics for the Cache Manager.
<2> Enables statistics for the named cache.
