12.3.6. Configurer un log handler de taille dans le CLI


Les log handlers de taille de fichiers en rotation peuvent être ajoutés, supprimés ou modifiés dans le CLI.
Voici les tâches qui vous reviendront pour configurer un log handler de taille de fichiers en rotations :
  • Ajouter un nouveau log handler
  • Afficher la configuration d'un log handler.
  • Définir le niveau de journalisation du handler.
  • Définir le comportement d'ajout du handler.
  • Définir si le handler utilise autoflush ou non.
  • Définir la codification utilisée pour la sortie du handler.
  • Indiquer le fichier dans lequel le log handler écrit.
  • Définir le formateur utilisé pour la sortie du handler.
  • Définir la taille maximum de chaque fichier journal.
  • Définir le nombre maximum de journaux de sauvegarde à conserver.
  • Définit l'option de démarrage de la rotation à l'amorçage pour le log handler de taille de fichiers.
  • Définir le suffixe pour les journaux en rotation.
  • Supprimer un log handler.
Chacune de ces tâches sont décrites ci-dessous.

Important

Pour la configuration d'un gestionnaire de journal dans un profil de journalisation de système autonome, la racine (root) du chemin de configuration est /subsystem=logging/logging-profile=NAME/ au lieu de /subsystem=logging/.
Dans un domaine géré, vous devez spécifier quel profil utiliser. Vous devez ajouter ule nom de profil en début de chemin de configuration pour un domaine géré, et remplacer /subsystem=logging/ par /profile=NAME/subsystem=logging/.
Ajouter un nouveau log handler
Utiliser l'opération add avec la syntaxe suivante.
Copy to Clipboard Toggle word wrap
 /subsystem=logging/size-rotating-file-handler=HANDLER:add(file={"path"=>"PATH", "relative-to"=>"DIR"}) 
Remplacer HANDLER par le nom du log handler. Remplacer PATH par le nom du fichier dans lequel le log est écrit. Remplacer DIR par le nom du répertoire dans lequel le fichier se trouve. La valeur DIR peut correspondre à une variable de chemin.

Exemple 12.41. Ajouter un nouveau log handler

Copy to Clipboard Toggle word wrap
[standalone@localhost:9999 /] /subsystem=logging/size-rotating-file-handler=ACCOUNTS_TRACE:add(file={"path"=>"accounts_trace.log", "relative-to"=>"jboss.server.log.dir"}) 
{"outcome" => "success"}
Afficher la configuration du log handler
Utiliser l'opération read-resource avec la syntaxe suivante.
Copy to Clipboard Toggle word wrap
 /subsystem=logging/size-rotating-file-handler=HANDLER:read-resource 
Remplacer HANDLER par le nom du log handler.

Exemple 12.42. Afficher la configuration du log handler

Copy to Clipboard Toggle word wrap
[standalone@localhost:9999 /] /subsystem=logging/size-rotating-file-handler=ACCOUNTS_TRACE:read-resource
{
    "outcome" => "success",
    "result" => {
        "append" => true,
        "enabled" => true,
        "autoflush" => true,
        "encoding" => undefined,
        "file" => {
            "path" => "accounts_trace.log",
            "relative-to" => "jboss.server.log.dir"
        },
        "filter" => undefined,
        "filter-spec" => undefined,
        "formatter" => "%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n",
        "level" => "ALL",
        "name" => "ACCOUNTS_TRACE"
        "named-formatter" => undefined,
        "max-backup-index" => 1,
        "rotate-size" => "2m"
        "rotate-on-boot" => false
    }
}
[standalone@localhost:9999 /]
Définir le niveau de journalisation du handler
Utiliser l'opération write-attribute avec la syntaxe suivante.
Copy to Clipboard Toggle word wrap
 /subsystem=logging/size-rotating-file-handler=HANDLER:write-attributel(name="level", value="LOG_LEVEL_VALUE") 
Remplacer HANDLER par le nom du log handler et LOG_LEVEL_VALUE par le niveau de journalisation à définir.

Exemple 12.43. Définir le niveau de journalisation du handler

Copy to Clipboard Toggle word wrap
[standalone@localhost:9999 /] /subsystem=logging/size-rotating-file-handler=ACCOUNTS_TRACE:write-attribute(name="level", value="TRACE")
{"outcome" => "success"}
[standalone@localhost:9999 /]
Définir le comportement d'ajout du handler.
Utiliser l'opération write-attribute avec la syntaxe suivante.
Copy to Clipboard Toggle word wrap
 /subsystem=logging/size-rotating-file-handler=HANDLER:write-attribute(name="append", value="BOOLEAN") 
Remplacer HANDLER par le nom du log handler. Remplacer BOOLÉEN par false si vous souhaitez qu'un nouveau fichier de journalisation soit créé à chaque fois qu'un serveur d'applications est lancé. Remplacer BOOLÉEN par true si le serveur d'applications doit continuer à utiliser le même fichier.
JBoss EAP 6 doit démarrer à nouveau pour prendre effet.

Exemple 12.44. Définir le comportement d'ajout du handler.

Copy to Clipboard Toggle word wrap
[standalone@localhost:9999 /] /subsystem=logging/size-rotating-file-handler=ACCOUNTS_TRACE:write-attribute(name="append", value="true")
{
    "outcome" => "success",
    "response-headers" => {
        "operation-requires-reload" => true,
        "process-state" => "reload-required"
    }
}
[standalone@localhost:9999 /]
Définir si le handler utilise autoflush ou non
Utiliser l'opération write-attribute avec la syntaxe suivante.
Copy to Clipboard Toggle word wrap
 /subsystem=logging/size-rotating-file-handler=HANDLER:write-attribute(name="autoflush", value="BOOLEAN") 
Remplacer HANDLER par le nom du log handler et BOOLEAN par true si le handler doit écrire sa sortie immédiatement.

Exemple 12.45. Définir si le handler utilise autoflush ou non

Copy to Clipboard Toggle word wrap
[standalone@localhost:9999 /] /subsystem=logging/size-rotating-file-handler=ACCOUNTS_TRACE:write-attribute(name="autoflush", value="true")
{"outcome" => "success"}
[standalone@localhost:9999 /]
Définir la codification utilisée pour la sortie du handler
Utiliser l'opération write-attribute avec la syntaxe suivante.
Copy to Clipboard Toggle word wrap
 /subsystem=logging/size-rotating-file-handler=HANDLER:write-attribute(name="encoding", value="ENCODING") 
Remplacer HANDLER par le nom du log handler et ENCODING par le nom de codification du caractère qui convient.

Exemple 12.46. Définir la codification utilisée pour la sortie du handler

Copy to Clipboard Toggle word wrap
[standalone@localhost:9999 /] /subsystem=logging/size-rotating-file-handler=ACCOUNTS_TRACE:write-attribute(name="encoding", value="utf-8") 
{"outcome" => "success"}]
Indiquer le fichier dans lequel le log handler écrit
Utiliser l'opération write-attribute avec la syntaxe suivante.
Copy to Clipboard Toggle word wrap
 /subsystem=logging/size-rotating-file-handler=HANDLER:write-attribute(name="file", value={"path"=>"PATH", "relative-to"=>"DIR"}) 
Remplacer HANDLER par le nom du log handler. Remplacer PATH par le nom du fichier dans lequel le log est écrit. Remplacer DIR par le nom du répertoire dans lequel le fichier se trouve. La valeur DIR peut correspondre à une variable de chemin.

Exemple 12.47. Indiquer le fichier dans lequel le log handler écrit

Copy to Clipboard Toggle word wrap
[standalone@localhost:9999 /] /subsystem=logging/size-rotating-file-handler=ACCOUNTS_TRACE:write-attribute(name="file", value={"path"=>"accounts_trace.log", "relative-to"=>"jboss.server.log.dir"}) 
{"outcome" => "success"}
Définir le formateur utilisé pour la sortie du handler.
Utiliser l'opération write-attribute avec la syntaxe suivante.
Copy to Clipboard Toggle word wrap
 /subsystem=logging/size-rotating-file-handler=HANDLER:write-attribute(name="formatter", value="FORMATTER") 
Remplacer HANDLER par le nom du log handler et FORMAT par le string de formateur à définir.

Exemple 12.48. Définir le formateur utilisé pour la sortie du handler.

Copy to Clipboard Toggle word wrap
[standalone@localhost:9999 /] /subsystem=logging/size-rotating-file-handler=ACCOUNTS_TRACE:write-attribute(name="formatter", value="%d{HH:mm:ss,SSS} %-5p (%c) [%t] %s%E%n")
{"outcome" => "success"}
Définir la taille maximum de chaque fichier de journalisation
Utiliser l'opération write-attribute avec la syntaxe suivante.
Copy to Clipboard Toggle word wrap
 /subsystem=logging/size-rotating-file-handler=HANDLER:write-attribute(name="rotate-size", value="SIZE") 
Remplacer HANDLER par le nom du log handler et SIZE par la taille de fichier maximum.

Exemple 12.49. Définir la taille maximum de chaque fichier de journalisation

Copy to Clipboard Toggle word wrap
[standalone@localhost:9999 /] /subsystem=logging/size-rotating-file-handler=ACCOUNTS_TRACE:write-attribute(name="rotate-size", value="50m")  
{"outcome" => "success"}
[standalone@localhost:9999 /]
Définir le nombre maximum de journaux de sauvegarde à conserver
Utiliser l'opération write-attribute avec la syntaxe suivante.
Copy to Clipboard Toggle word wrap
 /subsystem=logging/size-rotating-file-handler=HANDLER:write-attribute(name="max-backup-index", value="NUMBER") 
Remplacer HANDLER par le nom du log handler et NUMBER par le nombre de fichiers de journalisation à conserver.

Exemple 12.50. Définir le nombre maximum de journaux de sauvegarde à conserver

Copy to Clipboard Toggle word wrap
[standalone@localhost:9999 /] /subsystem=logging/size-rotating-file-handler=ACCOUNTS_TRACE:write-attribute(name="max-backup-index", value="5")
{"outcome" => "success"}
[standalone@localhost:9999 /]
Définit l'option de rotation au démarrage du size-rotating-file-handler
Cette option n'est disponible que pour le gestionnaire de fichiers size-rotating-file-handler. Une valeur par défaut de false indique qu'un nouveau fichier de journalisation n'est pas créé au redémarrage du serveur.
Pour changer cela, utiliser l'opération write-attribute avec la syntaxe suivante.
Copy to Clipboard Toggle word wrap
 /subsystem=logging/size-rotating-file-handler=HANDLER:write-attribute(name="rotate-on-boot", value="BOOLEAN") 
Remplacer HANDLER par le nom du log handler size-rotating-file-handler. Remplacer BOOLEAN par true si un nouveau fichier de journalisation size-rotating-file-handler doit être créé au redémarrage.

Exemple 12.51. Indique qu'il faut créer un nouveau fichier de journalisation size-rotating-file-handler lors du redémarrage du serveur.

Copy to Clipboard Toggle word wrap
[standalone@localhost:9999 /] /subsystem=logging/size-rotating-file-handler=ACCOUNTS_TRACE:write-attribute(name="rotate-on-boot", value="true")
{"outcome" => "success"}
[standalone@localhost:9999 /]
Définir le suffixe pour les journaux en rotation
Utiliser l'opération write-attribute avec la syntaxe suivante.
Copy to Clipboard Toggle word wrap
 /subsystem=logging/size-rotating-file-handler=HANDLER:write-attribute(name="suffix", value="SUFFIX") 
Remplacer HANDLER par le nom du log handler et SUFFIX par le string de suffixe à définir.

Exemple 12.52. 

Copy to Clipboard Toggle word wrap
[standalone@localhost:9999 /] /subsystem=logging/size-rotating-file-handler=ACCOUNTS_TRACE:write-attribute(name="suffix", value=".yyyy-MM-dd-HH")
{"outcome" => "success"}
[standalone@localhost:9999 /]
Supprimer un log handler
Utiliser l'opération remove avec la syntaxe suivante.
Copy to Clipboard Toggle word wrap
 /subsystem=logging/size-rotating-file-handler=HANDLER:remove 
Remplacer HANDLER par le nom du log handler.

Exemple 12.53. Supprimer un log handler

Copy to Clipboard Toggle word wrap
[standalone@localhost:9999 /] /subsystem=logging/size-rotating-file-handler=ACCOUNTS_TRACE:remove
{"outcome" => "success"}
Retour au début
Red Hat logoGithubredditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance. Découvrez nos récentes mises à jour.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez le Blog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

Theme

© 2025 Red Hat, Inc.