Journalisation des applications¶
This section covers application logging in DHIS2.
Fichiers journaux¶
The DHIS2 application log output is directed to multiple files and locations. First, log output is sent to standard output. The Tomcat servlet container usually outputs standard output to a file under "logs":
<tomcat-dir>/logs/catalina.out
Second, log output is written to a "logs" directory under the DHIS2 home directory as defined by the DHIS2_HOME environment variables. There is a main log file for all output, and separate log files for various background processes. The main file includes the background process logs as well. The log files are capped at 50 Mb and log content is continuously appended.
<DHIS2_HOME>/logs/dhis.log
<DHIS2_HOME>/logs/dhis-analytics-table.log
<DHIS2_HOME>/logs/dhis-data-exchange.log
<DHIS2_HOME>/logs/dhis-data-sync.log
Configuration du journal¶
Pour remplacer la configuration du journal par défaut, vous pouvez spécifier une propriété de système Java avec le nom log4j2.configurationFile et une valeur orientée vers le fichier de configuration Log4j version 2 sur le système de fichiers comme ce qui suit :
-Dlog4j2.configurationFile=/home/dhis/config/log4j2.properties
Java system properties can be set e.g. through the JAVA_OPTS environment variable or in the tomcat startup script.
A second approach to overriding the log configuration is to specify logging properties in the dhis.conf configuration file. The supported properties are:
# Taille maximale des fichiers journaux, la valeur par défaut est '100Mo'
journalisation.file.max_size = 250 Mo
# Nombre maximum de fichiers d'archives de journaux évolutifs, la valeur par défaut est 0
journalisation.file.max_archives = 2
DHIS2 will eventually phase out logging to standard out / catalina.out and as a result it is recommended to rely on the logs under DHIS2_HOME.
DHIS2 fournira les valeurs de contexte suivantes :
sessionId: ID de session de l'utilisateur actuelxRequestID: An alphanumeric ID as send by theX-Request-IDHTTP header for the currently processed request; empty if not provided
To use the context variables in the log add them using -X{<name>} to your log pattern as in this example:
* %-5p %d{ISO8601} %m (%F [%t]) %X{sessionId} %X{xRequestID}%n
Configuration du niveau de journalisation¶
To set the log level of individual packages you can specify properties on the format logging.level.{package-names} in dhis.conf. For example, to set the log level for the entire Spring Framework to DEBUG and up, you can specify:
logging.level.org.springframework = DEBUG
logging.level.org.hisp.dhis = DEBUG
Les niveaux de journalisation courants sont DEBUG, INFO, WARN et ERROR.
Remarque
La configuration du niveau du journal n'est pas prise en charge par la version intégrée de DHIS2 Jetty.
Journal des modifications¶
DHIS2 writes entries to changelogs when certain entities were changed in the system. The entities fall within two categories: Aggregate and tracker. The aggregate category includes changes to aggregate data values. The tracker category includes changes to tracked entity attribute values and event data values.
The benefit of the changelog is the ability to see changes which have been performed to the data. The benefits of disabling the changelog is a minor performance improvement by avoiding the cost of writing changelog items to the database, and less database storage used. It is recommended to enable changelog, and great care should be taken if disabling it.
The aggregate changelog is enabled by default. You can control its behavior through the dhis.conf configuration file using the following property. Available options are on (default) and off:
# Aggregate changelog, can be 'on' (default), 'off'
changelog.aggregate = on
The tracker changelog is configured per program and tracked entity type. In the maintenance app, you can enable or disable change logs individually for each program and tracked entity type.