13.3.5. Configurer un Log Handler périodique dans le CLI
Les Log Handlers périodiques peuvent être ajoutés, supprimés ou modifiés dans le CLI.
Voici les tâches principales qui vous reviendront pour configurer un Log Handler périodique :
- Ajouter un nouveau Log Handler périodique.
- Afficher la configuration d'un Log Handler périodique
- 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 le suffixe pour les journaux en rotation
- Supprimer un Log Handler périodique
Chacune de ces actions sont décrites ci-dessous.
Important
Pour la configuration d'un handler de journalisation dans un profil de journalisation, la racine (root) du chemin de configuration est
/subsystem=logging/logging-profile=NAME/
au lieu de /subsystem=logging/
.
- Ajouter un nouveau Log Handler périodique en rotation.
- Utiliser l'opération
add
avec la syntaxe suivante./subsystem=logging/periodic-rotating-file-handler=HANDLER:add(file={"path"=>"PATH", "relative-to"=>"DIR"}, suffix="SUFFIX")
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. Remplacer SUFFIX par le suffixe de rotation de fichiers à utiliser.Exemple 13.29. Créer un nouvel handler
[standalone@localhost:9999 /] /subsystem=logging/periodic-rotating-file-handler=HOURLY_DEBUG:add(file={"path"=>"daily-debug.log", "relative-to"=>"jboss.server.log.dir"}, suffix=".yyyy.MM.dd") {"outcome" => "success"} [standalone@localhost:9999 /]
- Afficher une configuration de Log Handler de fichiers en rotation périodique
- Utiliser l'opération
read-resource
avec la syntaxe suivante./subsystem=logging/periodic-rotating-file-handler=HANDLER:read-resource
Remplacer HANDLER par le nom du Log Handler.Exemple 13.30. Utiliser l'opération read-resource
[standalone@localhost:9999 /] /subsystem=logging/periodic-rotating-file-handler=HOURLY_DEBUG:read-resource { "outcome" => "success", "result" => { "append" => true, "autoflush" => true, "encoding" => undefined, "file" => { "path" => "daily-debug.log", "relative-to" => "jboss.server.log.dir" }, "filter" => undefined, "formatter" => "%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n", "level" => undefined } } [standalone@localhost:9999 /]
- Définir Niveau de journalisation
- Utiliser l'opération
change-log-level
avec la syntaxe suivante./subsystem=logging/periodic-rotating-file-handler=HANDLER:change-log-level(level="LEVEL")
Remplacer HANDLER par le nom du Log Handler périodique et LEVEL par le niveau de journalisation à définir.Exemple 13.31. Définir le niveau de journalisation
[standalone@localhost:9999 /] /subsystem=logging/periodic-rotating-file-handler=HOURLY_DEBUG:change-log-level(level="DEBUG") {"outcome" => "success"} [standalone@localhost:9999 /]
- Définir le comportement d'ajout
- Utiliser l'opération
write-attribute
avec la syntaxe suivante./subsystem=logging/periodic-rotating-handler=HANDLER:write-attribute(name="append", value="BOOLEAN")
Remplacer HANDLER par le nom du Log Handler périodique. Remplacer BOOLÉEN parfalse
si vous souhaitez qu'un nouveau fichier de journalisation soit créé à chaque fois qu'un serveur d'applications est lancé. Remplacer BOOLÉEN partrue
si le serveur d'applications doit continuer à utiliser le même fichier.JBoss Enterprise Application Platform 6 doit démarrer à nouveau pour prendre effet.Exemple 13.32. Définir le comportement d'ajout
[standalone@localhost:9999 /] /subsystem=logging/periodic-rotating-file-handler=HOURLY_DEBUG:write-attribute(name="append", value="true") { "outcome" => "success", "response-headers" => { "operation-requires-reload" => true, "process-state" => "reload-required" } } [standalone@localhost:9999 /]
- Définir Auto Flush
- Utiliser l'opération
write-attribute
avec la syntaxe suivante./subsystem=logging/periodic-rotating-file-handler=HANDLER:write-attribute(name="autoflush", value="BOOLEAN")
Remplacer HANDLER par le nom du Log Handler périodique et BOOLEAN partrue
si le handler doit écrite sa sortie immédiatement.JBoss Enterprise Application Platform 6 doit démarrer à nouveau pour prendre effet.Exemple 13.33. Définir le comportement Auto Flush
[standalone@localhost:9999 /] /subsystem=logging/periodic-rotating-file-handler=HOURLY_DEBUG:write-attribute(name="autoflush", value="false") { "outcome" => "success", "response-headers" => {"process-state" => "reload-required"} } [standalone@localhost:9999 /]
- Définir le Codage
- Utiliser l'opération
write-attribute
avec la syntaxe suivante./subsystem=logging/periodic-rotating-file-handler=HANDLER:write-attribute(name="encoding", value="ENCODING")
Remplacer HANDLER par le nom du Log Handler périodique et ENCODING par le nom de codification du caractère qui convient.Exemple 13.34. Définir le Codage
[standalone@localhost:9999 /] /subsystem=logging/periodic-rotating-file-handler=HOURLY_DEBUG:write-attribute(name="encoding", value="utf-8") {"outcome" => "success"} [standalone@localhost:9999 /]
- Changer le fichier dans lequel le Log Handler écrit.
- Utiliser l'opération
change-file
avec la syntaxe suivante./subsystem=logging/periodic-rotating-file-handler=HANDLER:change-file(file={"path"=>"PATH", "relative-to"=>"DIR"})
Remplacer HANDLER par le nom du Log Handler périodique. 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 13.35. Changer le fichier dans lequel le Log Handler écrit.
[standalone@localhost:9999 /] /subsystem=logging/periodic-rotating-file-handler=HOURLY_DEBUG:change-file(file={"path"=>"daily-debug.log", "relative-to"=>"jboss.server.log.dir"}) {"outcome" => "success"} [standalone@localhost:9999 /]
- Définir Formateur
- Utiliser l'opération
write-attribute
avec la syntaxe suivante./subsystem=logging/periodic-rotating-file-handler=HANDLER:write-attribute(name="formatter", value="FORMAT")
Remplacer HANDLER par le nom du Log Handler périodique et FORMAT par le string de formateur à définir.Exemple 13.36. Définir Formateur
[standalone@localhost:9999 /] /subsystem=logging/periodic-rotating-file-handler=HOURLY_DEBUG:write-attribute(name="formatter", value="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n") {"outcome" => "success"} [standalone@localhost:9999 /]
- Définir le suffixe pour les journaux en rotation
- Utiliser l'opération
write-attribute
avec la syntaxe suivante./subsystem=logging/periodic-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 13.37.
[standalone@localhost:9999 /] /subsystem=logging/periodic-rotating-file-handler=HOURLY_DEBUG:write-attribute(name="suffix", value=".yyyy-MM-dd-HH") {"outcome" => "success"} [standalone@localhost:9999 /]
- Supprimer un Log Handler périodique
- Utiliser l'opération
remove
avec la syntaxe suivante./subsystem=logging/periodic-rotating-file-handler=HANDLER:remove
Remplacer HANDLER par le nom du Log Handler périodique.Exemple 13.38. Supprimer un Log Handler périodique
[standalone@localhost:9999 /] /subsystem=logging/periodic-rotating-file-handler=HOURLY_DEBUG:remove {"outcome" => "success"} [standalone@localhost:9999 /]