12.3. Logging Configuration in the CLI


Prerequisite

The Management CLI must be running and connected to the relevant JBoss EAP instance. For further information see Section 3.4.2, “Launch the Management CLI”

12.3.1. Configure the Root Logger with the CLI

The root logger configuration can be viewed and edited using the Management CLI.
The main tasks you will perform to configure the root logger are:
  • Add log handlers to the root logger.
  • Display the root logger configuration.
  • Change the log level.
  • Remove log handlers from the root logger.

Important

When configuring a root logger in a logging profile for a standalone system, the root of the configuration path is /subsystem=logging/logging-profile=NAME/ instead of /subsystem=logging/.
For a managed domain, you must specify which profile to use. You must add the profile name to the beginning of the configuration path for a managed domain, replacing /subsystem=logging/ with /profile=NAME/subsystem=logging/.
Add a Log Handler to the Root Logger
Use the add-handler operation with the following syntax where HANDLER is the name of the log handler to be added.
/subsystem=logging/root-logger=ROOT:add-handler(name="HANDLER")
The log handler must already have been created before it can be added to the root logger.

Example 12.3. Root Logger add-handler operation

[standalone@localhost:9999 /] /subsystem=logging/root-logger=ROOT:add-handler(name="FILE")
{"outcome" => "success"}
Display the Contents of the Root Logger Configuration
Use the read-resource operation with the following syntax.
/subsystem=logging/root-logger=ROOT:read-resource

Example 12.4. Root Logger read-resource operation

[standalone@localhost:9999 /] /subsystem=logging/root-logger=ROOT:read-resource                                  
{
   "outcome" => "success",
   "result" => {
        "filter" => undefined,
        "filter-spec" => undefined,
        "handlers" => [
            "CONSOLE",
            "FILE"
      ],
      "level" => "INFO"
   }
}
Set the Log Level of the Root Logger
Use the write-attribute operation with the following syntax where LEVEL is one of the supported log levels.
/subsystem=logging/root-logger=ROOT:write-attribute(name="level", value="LEVEL")

Example 12.5. Root Logger write-attribute operation to set the log level

[standalone@localhost:9999 /] /subsystem=logging/root-logger=ROOT:write-attribute(name="level", value="DEBUG")
{"outcome" => "success"}
Remove a Log Handler from the Root Logger
Use the remove-handler with the following syntax, where HANDLER is the name of the log handler to be removed.
/subsystem=logging/root-logger=ROOT:remove-handler(name="HANDLER")

Example 12.6. Remove a Log Handler

[standalone@localhost:9999 /] /subsystem=logging/root-logger=ROOT:remove-handler(name="FILE")
{"outcome" => "success"}

12.3.2. Configure a Log Category in the CLI

Log categories can be added, removed and edited in the CLI.
The main tasks you will perform to configure a log category are:
  • Add a new log category.
  • Display the configuration of a log category.
  • Set the log level.
  • Add log handlers to a log category.
  • Remove log handlers from a log category.
  • Remove a log category.

Important

When configuring a log category in a logging profile for a standalone system, the root of the configuration path is /subsystem=logging/logging-profile=NAME/ instead of /subsystem=logging/.
For a managed domain, you must specify which profile to use. You must add the profile name to the beginning of the configuration path for a managed domain, replacing /subsystem=logging/ with /profile=NAME/subsystem=logging/.
Add a log category
Use the add operation with the following syntax. Replace CATEGORY with the category to be added.
 /subsystem=logging/logger=CATEGORY:add 

Example 12.7. Adding a new log category

[standalone@localhost:9999 /] /subsystem=logging/logger=com.company.accounts.rec:add   
{"outcome" => "success"}
Display a log category configuration
Use the read-resource operation with the following syntax. Replace CATEGORY with the name of the category.
/subsystem=logging/logger=CATEGORY:read-resource 

Example 12.8. Log Category read-resource operation

[standalone@localhost:9999 /] /subsystem=logging/logger=org.apache.tomcat.util.modeler:read-resource
{
    "outcome" => "success",
    "result" => {
        "category" => "org.apache.tomcat.util.modeler",
        "filter" => undefined,
        "filter-spec" => undefined,
        "handlers" => undefined,
        "level" => "WARN",
        "use-parent-handlers" => true
    }
}
Set the log level
Use the write-attribute operation with the following syntax. Replace CATEGORY with the name of the log category and LEVEL with the log level that is to be set.
/subsystem=logging/logger=CATEGORY:write-attribute(name="level", value="LEVEL") 

Example 12.9. Setting a log level

[standalone@localhost:9999 /] /subsystem=logging/logger=com.company.accounts.rec:write-attribute(name="level", value="DEBUG")
{"outcome" => "success"}
Set the log category to use the log handlers of the root logger.
Use the write-attribute operation with the following syntax. Replace CATEGORY with the name of the log category. Replace BOOLEAN with true for this log category to use the handlers of the root logger. Replace it with false if it is to use only its own assigned handlers.
/subsystem=logging/logger=CATEGORY:write-attribute(name="use-parent-handlers", value="BOOLEAN") 

Example 12.10. Setting use-parent-handlers

[standalone@localhost:9999 /] /subsystem=logging/logger=com.company.accounts.rec:write-attribute(name="use-parent-handlers", value="true")
{"outcome" => "success"}
Add a log handlers to a log category
Use the add-handler operation with the following syntax. Replace CATEGORY with the name of the category and HANDLER with the name of the handler to be added.
/subsystem=logging/logger=CATEGORY:add-handler(name="HANDLER") 
The log handler must already have been created before it can be added to the root logger.

Example 12.11. Adding a log handler

[standalone@localhost:9999 /] /subsystem=logging/logger=com.company.accounts.rec:add-handler(name="AccountsNFSAsync")
{"outcome" => "success"}
Remove a log handler from a log category
Use the remove-handler operation with the following syntax. Replace CATEGORY with the name of the category and HANDLER with the name of the log handler to be removed.
/subsystem=logging/logger=CATEGORY:remove-handler(name="HANDLER")

Example 12.12. Removing a log handler

[standalone@localhost:9999 /] /subsystem=logging/logger=jacorb:remove-handler(name="AccountsNFSAsync")
{"outcome" => "success"}
Remove a category
Use the remove operation with the following syntax. Replace CATEGORY with the name of the category to be removed.
/subsystem=logging/logger=CATEGORY:remove 

Example 12.13. Removing a log category

[standalone@localhost:9999 /] /subsystem=logging/logger=com.company.accounts.rec:remove   
{"outcome" => "success"}

12.3.3. Configure a Console Log Handler in the CLI

Console log handlers can be added, removed and edited in the CLI.
The main tasks you will perform to configure a console log handler are:
  • Add a new console log handler.
  • Display the configuration of a console log handler.
  • Set the handler's log level.
  • Set the target for the handler's output.
  • Set the encoding used for the handler's output.
  • Set the formatter used for the handler's output.
  • Set whether the handler uses autoflush or not.
  • Remove a console log handler.

Important

When configuring a log handler in a logging profile for a standalone system, the root of the configuration path is /subsystem=logging/logging-profile=NAME/ instead of /subsystem=logging/.
For a managed domain, you must specify which profile to use. You must add the profile name to the beginning of the configuration path for a managed domain, replacing /subsystem=logging/ with /profile=NAME/subsystem=logging/.
Add a Console Log Handler
Use the add operation with the following syntax. Replace HANDLER with the console log handler to be added.
/subsystem=logging/console-handler=HANDLER:add 

Example 12.14. Add a Console Log Handler

[standalone@localhost:9999 /] /subsystem=logging/console-handler=ERRORCONSOLE:add     
{"outcome" => "success"}
Display a console log handler configuration
Use the read-resource operation with the following syntax. Replace HANDLER with the name of the console log handler.
/subsystem=logging/console-handler=HANDLER:read-resource 

Example 12.15. Display a console log handler configuration

[standalone@localhost:9999 /] /subsystem=logging/console-handler=CONSOLE:read-resource
{
    "outcome" => "success",
    "result" => {
        "autoflush" => true,
        "enabled" => true,
        "encoding" => undefined,
        "filter" => undefined,
        "filter-spec" => undefined,
        "formatter" => "%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n",
        "level" => "INFO",
        "name" => "CONSOLE",
        "named-formatter" => "COLOR-PATTERN",
        "target" => "System.out"
    }
}
Set the Log Level
Use the write-attribute operation with the following syntax. Replace HANDLER with the name of the console log handler and LEVEL with the log level that is to be set.
/subsystem=logging/console-handler=HANDLER:write-attribute(name="level", value="INFO") 

Example 12.16. Set the Log Level

[standalone@localhost:9999 /] /subsystem=logging/console-handler=ERRORCONSOLE:write-attribute(name="level", value="TRACE")
{"outcome" => "success"}
Set the Target
Use the write-attribute operation with the following syntax. Replace HANDLER with the name of the console log handler. Replace TARGET with either System.err or System.out for the system error stream or standard out stream respectively.
/subsystem=logging/console-handler=HANDLER:write-attribute(name="target", value="TARGET") 

Example 12.17. Set the Target

[standalone@localhost:9999 /] /subsystem=logging/console-handler=ERRORCONSOLE:write-attribute(name="target", value="System.err")
{"outcome" => "success"}
Set the Encoding
Use the write-attribute operation with the following syntax. Replace HANDLER with the name of the console log handler. Replace ENCODING with the name of the required character encoding system.
/subsystem=logging/console-handler=HANDLER:write-attribute(name="encoding", value="ENCODING") 

Example 12.18. Set the Encoding

[standalone@localhost:9999 /] /subsystem=logging/console-handler=ERRORCONSOLE:write-attribute(name="encoding", value="utf-8")     
{"outcome" => "success"}
Set the Formatter
Use the write-attribute operation with the following syntax. Replace HANDLER with the name of the console log handler. Replace FORMAT with the required formatter string.
/subsystem=logging/console-handler=HANDLER:write-attribute(name="formatter", value="FORMAT") 

Example 12.19. Set the Formatter

[standalone@localhost:9999 /] /subsystem=logging/console-handler=ERRORCONSOLE:write-attribute(name="formatter", value="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n")
{"outcome" => "success"}
Set the Auto Flush
Use the write-attribute operation with the following syntax. Replace HANDLER with the name of the console log handler. Replace BOOLEAN with true if this handler is to immediately write its output.
/subsystem=logging/console-handler=HANDLER:write-attribute(name="autoflush", value="BOOLEAN") 

Example 12.20. Set the Auto Flush

[standalone@localhost:9999 /] /subsystem=logging/console-handler=ERRORCONSOLE:write-attribute(name="autoflush", value="true")                                  
{"outcome" => "success"}
Remove a Console Log Handler
Use the remove operation with the following syntax. Replace HANDLER with the name of the console log handler to be removed.
/subsystem=logging/console-handler=HANDLER:remove 

Example 12.21. Remove a Console Log Handler

[standalone@localhost:9999 /] /subsystem=logging/console-handler=ERRORCONSOLE:remove
{"outcome" => "success"}

12.3.4. Configure a File Log Handler in the CLI

File log handlers can be added, removed and edited in the CLI.
The main tasks you will perform to configure a file log handler are:
  • Add a new file log handler.
  • Display the configuration of a file log handler
  • Set the handler's log level.
  • Set the handler's appending behavior.
  • Set whether the handler uses autoflush or not.
  • Set the encoding used for the handler's output.
  • Specify the file to which the log handler will write.
  • Set the formatter used for the handler's output.
  • Remove a file log handler.

Important

When configuring a log handler in a logging profile for a standalone system, the root of the configuration path is /subsystem=logging/logging-profile=NAME/ instead of /subsystem=logging/.
For a managed domain, you must specify which profile to use. You must add the profile name to the beginning of the configuration path for a managed domain, replacing /subsystem=logging/ with /profile=NAME/subsystem=logging/.
Add a file log handler
Use the add operation with the following syntax. Replace PATH with the filename for the file that the log is being written to. Replace DIR with the name of the directory where the file is to be located. The value of DIR can be a path variable.
 /subsystem=logging/file-handler=HANDLER:add(file={"path"=>"PATH", "relative-to"=>"DIR"}) 

Example 12.22. Add a file log handler

[standalone@localhost:9999 /] /subsystem=logging/file-handler=accounts_log:add(file={"path"=>"accounts.log", "relative-to"=>"jboss.server.log.dir"})
{"outcome" => "success"}
Display a file log handler configuration
Use the read-resource operation with the following syntax. Replace HANDLER with the name of the file log handler.
 /subsystem=logging/file-handler=HANDLER:read-resource 

Example 12.23. Using the read-resource operation

[standalone@localhost:9999 /] /subsystem=logging/file-handler=accounts_log:read-resource
{
    "outcome" => "success",
    "result" => {
        "append" => true,
        "autoflush" => true,
        "enabled" => true,
        "encoding" => undefined,
        "file" => {
            "path" => "accounts.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_log",
        "named-formatter" => undefined
    }
}
Set the Log level
Use the write-attribute operation with the following syntax. Replace HANDLER with the name of the file log handler. Replace LOG_LEVEL_VALUE with the log level that is to be set.
 /subsystem=logging/file-handler=HANDLER:write-attribute(name="level", value="LOG_LEVEL_VALUE") 

Example 12.24. Changing the log level

/subsystem=logging/file-handler=accounts_log:write-attribute(name="level", value="DEBUG")
{"outcome" => "success"}
Set the append behaviour
Use the write-attribute operation with the following syntax. Replace HANDLER with the name of the file log handler. Replace BOOLEAN with false if you required that a new log file be created each time the application server is launched. Replace BOOLEAN with true if the application server should continue to use the same file.
 /subsystem=logging/file-handler=HANDLER:write-attribute(name="append", value="BOOLEAN") 

Example 12.25. Changing the append property

[standalone@localhost:9999 /] /subsystem=logging/file-handler=accounts_log:write-attribute(name="append", value="true")
{
    "outcome" => "success",
    "response-headers" => {
        "operation-requires-reload" => true,
        "process-state" => "reload-required"
    }
}
JBoss EAP 6 must be restarted for this change to take effect.
Set the Auto Flush
Use the write-attribute operation with the following syntax. Replace HANDLER with the name of the file log handler. Replace BOOLEAN with true if this handler is to immediately write its output.
 /subsystem=logging/file-handler=HANDLER:write-attribute(name="autoflush", value="BOOLEAN") 

Example 12.26. Changing the autoflush property

[standalone@localhost:9999 /] /subsystem=logging/file-handler=accounts_log:write-attribute(name="autoflush", value="false")
{"outcome" => "success"}
Set the Encoding
Use the write-attribute operation with the following syntax. Replace HANDLER with the name of the file log handler. Replace ENCODING with the name of the required character encoding system.
 /subsystem=logging/file-handler=HANDLER:write-attribute(name="encoding", value="ENCODING") 

Example 12.27. Set the Encoding

[standalone@localhost:9999 /] /subsystem=logging/file-handler=accounts_log:write-attribute(name="encoding", value="utf-8")     
{"outcome" => "success"}
Change the file to which the log handler writes
Use the write-attribute operation with the following syntax. Replace PATH with the filename for the file that the log is being written to. Replace DIR with the name of the directory where the file is to be located. The value of DIR can be a path variable.
 /subsystem=logging/file-handler=HANDLER:write-attribute(name="file", value={"path"=>"PATH", "relative-to"=>"DIR"}) 

Example 12.28. Change the file to which the log handler writes

[standalone@localhost:9999 /] /subsystem=logging/file-handler=accounts_log:write-attribute(name="file", value={"path"=>"accounts-debug.log", "relative-to"=>"jboss.server.log.dir"})
{"outcome" => "success"}
Set the Formatter
Use the write-attribute operation with the following syntax. Replace HANDLER with the name of the file log handler. Replace FORMAT with the required formatter string.
 /subsystem=logging/file-handler=HANDLER:write-attribute(name="formatter", value="FORMAT") 

Example 12.29. Set the Formatter

[standalone@localhost:9999 /] /subsystem=logging/file-handler=accounts_log:write-attribute(name="formatter", value="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n")
{"outcome" => "success"}
Remove a File Log Handler
Use the remove operation with the following syntax. Replace HANDLER with the name of the file log handler to be removed.
 /subsystem=logging/file-handler=HANDLER:remove 

Example 12.30. Remove a File Log Handler

[standalone@localhost:9999 /] /subsystem=logging/file-handler=accounts_log:remove
{"outcome" => "success"}
A log handler can only be removed if it is not being referenced by a log category or an async log handler.

12.3.5. Configure a Periodic Log Handler in the CLI

Periodic log handlers can be added, removed and edited in the CLI.
The main tasks you will perform to configure a periodic log handler are:
  • Add a new periodic log handler.
  • Display the configuration of a periodic log handler
  • Set the handler's log level.
  • Set the handler's appending behavior.
  • Set whether or not the handler uses autoflush.
  • Set the encoding used for the handler's output.
  • Specify the file to which the log handler will write.
  • Set the formatter used for the handler's output.
  • Set the suffix for rotated logs.
  • Remove a periodic log handler.
Each of those tasks are described below.

Important

When configuring a log handler in a logging profile for a standalone system, the root of the configuration path is /subsystem=logging/logging-profile=NAME/ instead of /subsystem=logging/.
For a managed domain, you must specify which profile to use. You must add the profile name to the beginning of the configuration path for a managed domain, replacing /subsystem=logging/ with /profile=NAME/subsystem=logging/.
Add a new Periodic Rotating File log handler
Use the add operation with the following syntax.
 /subsystem=logging/periodic-rotating-file-handler=HANDLER:add(file={"path"=>"PATH", "relative-to"=>"DIR"}, suffix="SUFFIX") 
Replace HANDLER with the name of the log handler. Replace PATH with the filename for the file that the log is being written to. Replace DIR with the name of the directory where the file is to be located. The value of DIR can be a path variable. Replace SUFFIX with the file rotation suffix to be used.

Example 12.31. Add a new 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"}
Display a Periodic Rotating File log handler configuration
Use the read-resource operation with the following syntax.
 /subsystem=logging/periodic-rotating-file-handler=HANDLER:read-resource 
Replace HANDLER with the name of the log handler.

Example 12.32. Using the read-resource operation

[standalone@localhost:9999 /] /subsystem=logging/periodic-rotating-file-handler=HOURLY_DEBUG:read-resource
{
    "outcome" => "success",
    "result" => {
        "append" => true,
        "autoflush" => true,
        "enabled" => true,
        "encoding" => undefined,
        "file" => {
            "path" => "daily-debug.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" => "HOURLY_DEBUG",
        "named-formatter" => undefined,
        "suffix" => ".yyyy.MM.dd"
    },
    "response-headers" => {"process-state" => "reload-required"}
}
Set the Log level
Use the write-attribute operation with the following syntax.
 /subsystem=logging/periodic-rotating-file-handler=HANDLER:write-attribute(name="level". value="LOG_LEVEL_VALUE") 
Replace HANDLER with the name of the periodic log handler. Replace LOG_LEVEL_VALUE with the log level that is to be set.

Example 12.33. Set the log level

[standalone@localhost:9999 /] /subsystem=logging/periodic-rotating-file-handler=HOURLY_DEBUG:write-attribute(name="level", value="DEBUG")
{"outcome" => "success"}
Set the append behavior
Use the write-attribute operation with the following syntax.
 /subsystem=logging/periodic-rotating-handler=HANDLER:write-attribute(name="append", value="BOOLEAN") 
Replace HANDLER with the name of the periodic log handler. Replace BOOLEAN with false if you required that a new log file be created each time the application server is launched. Replace BOOLEAN with true if the application server should continue to use the same file.
JBoss EAP 6 must be restarted for this change to take effect.

Example 12.34. Set the append behavior

[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"
    }
}
Set the Auto Flush
Use the write-attribute operation with the following syntax.
 /subsystem=logging/periodic-rotating-file-handler=HANDLER:write-attribute(name="autoflush", value="BOOLEAN") 
Replace HANDLER with the name of the periodic log handler. Replace BOOLEAN with true if this handler is to immediately write its output.

Example 12.35. Set the Auto Flush behavior

[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"}
}
Set the Encoding
Use the write-attribute operation with the following syntax.
 /subsystem=logging/periodic-rotating-file-handler=HANDLER:write-attribute(name="encoding", value="ENCODING") 
Replace HANDLER with the name of the periodic log handler. Replace ENCODING with the name of the required character encoding system.

Example 12.36. Set the Encoding

[standalone@localhost:9999 /] /subsystem=logging/periodic-rotating-file-handler=HOURLY_DEBUG:write-attribute(name="encoding", value="utf-8")     
{"outcome" => "success"}
Change the file to which the log handler writes
Use the write-attribute operation with the following syntax.
 /subsystem=logging/periodic-rotating-file-handler=HANDLER:write-attribute(name="file", value={"path"=>"PATH", "relative-to"=>"DIR"}) 
Replace HANDLER with the name of the periodic log handler. Replace PATH with the filename for the file that the log is being written to. Replace DIR with the name of the directory where the file is to be located. The value of DIR can be a path variable.

Example 12.37. Change the file to which the log handler writes

[standalone@localhost:9999 /] /subsystem=logging/periodic-rotating-file-handler=HOURLY_DEBUG:write-attribute(name="file", value={"path"=>"daily-debug.log", "relative-to"=>"jboss.server.log.dir"})
{"outcome" => "success"}
Set the Formatter
Use the write-attribute operation with the following syntax.
 /subsystem=logging/periodic-rotating-file-handler=HANDLER:write-attribute(name="formatter", value="FORMAT") 
Replace HANDLER with the name of the periodic log handler. Replace FORMAT with the required formatter string.

Example 12.38. Set the Formatter

[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"}
Set the suffix for rotated logs
Use the write-attribute operation with the following syntax.
 /subsystem=logging/periodic-rotating-file-handler=HANDLER:write-attribute(name="suffix", value="SUFFIX") 
Replace HANDLER with the name of the log handler. Replace SUFFIX with the required suffix string.

Example 12.39. Set the suffix for rotated log

[standalone@localhost:9999 /] /subsystem=logging/periodic-rotating-file-handler=HOURLY_DEBUG:write-attribute(name="suffix", value=".yyyy-MM-dd-HH")
{"outcome" => "success"}
Remove a periodic log handler
Use the remove operation with the following syntax.
 /subsystem=logging/periodic-rotating-file-handler=HANDLER:remove 
Replace HANDLER with the name of the periodic log handler.

Example 12.40. Remove a periodic log handler

[standalone@localhost:9999 /] /subsystem=logging/periodic-rotating-file-handler=HOURLY_DEBUG:remove
{"outcome" => "success"}

12.3.6. Configure a Size Log Handler in the CLI

Size rotated file log handlers can be added, removed and edited in the CLI.
The tasks you will perform to configure a size rotated file log handler are:
  • Add a new log handler.
  • Display the configuration of the log handler.
  • Set the handler's log level.
  • Set the handler's appending behavior.
  • Set whether the handler uses autoflush or not.
  • Set the encoding used for the handler's output.
  • Specify the file to which the log handler will write.
  • Set the formatter used for the handler's output.
  • Set the maximum size of each log file.
  • Set the maximum number of backup logs to keep.
  • Set the rotate on boot option for the size rotation file handler.
  • Set the suffix for rotated logs.
  • Remove a log handler.
Each of these tasks are described below.

Important

When configuring a log handler in a logging profile for a standalone system, the root of the configuration path is /subsystem=logging/logging-profile=NAME/ instead of /subsystem=logging/.
For a managed domain, you must specify which profile to use. You must add the profile name to the beginning of the configuration path for a managed domain, replacing /subsystem=logging/ with /profile=NAME/subsystem=logging/.
Add a new log handler
Use the add operation with the following syntax.
 /subsystem=logging/size-rotating-file-handler=HANDLER:add(file={"path"=>"PATH", "relative-to"=>"DIR"}) 
Replace HANDLER with the name of the log handler. Replace PATH with the filename for the file that the log is being written to. Replace DIR with the name of the directory where the file is to be located. The value of DIR can be a path variable.

Example 12.41. Add a new log handler

[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"}
Display the configuration of the log handler
Use the read-resource operation with the following syntax.
 /subsystem=logging/size-rotating-file-handler=HANDLER:read-resource 
Replace HANDLER with the name of the log handler.

Example 12.42. Display the configuration of the log handler

[standalone@localhost:9999 /] /subsystem=logging/size-rotating-file-handler=ACCOUNTS_TRACE:read-resource
{
    "outcome" => "success",
    "result" => {
        "append" => true,
        "autoflush" => true,
        "enabled" => 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",
        "max-backup-index" => 1,
        "name" => "ACCOUNTS_TRACE",
        "named-formatter" => undefined,
        "rotate-on-boot" => false,
        "rotate-size" => "2m",
        "suffix" => undefined
    }
}
Set the handler's log level
Use the write-attribute operation with the following syntax.
 /subsystem=logging/size-rotating-file-handler=HANDLER:write-attributel(name="level", value="LOG_LEVEL_VALUE") 
Replace HANDLER with the name of the log handler. Replace LOG_LEVEL_VALUE with the log level that is to be set.

Example 12.43. Set the handler's log level

[standalone@localhost:9999 /] /subsystem=logging/size-rotating-file-handler=ACCOUNTS_TRACE:write-attribute(name="level", value="TRACE")
{"outcome" => "success"}
Set the handler's appending behavior
Use the write-attribute operation with the following syntax.
 /subsystem=logging/size-rotating-file-handler=HANDLER:write-attribute(name="append", value="BOOLEAN") 
Replace HANDLER with the name of the log handler. Replace BOOLEAN with false if you required that a new log file be created each time the application server is launched. Replace BOOLEAN with true if the application server should continue to use the same file.
JBoss EAP 6 must be restarted for this change to take effect.

Example 12.44. Set the handler's appending behavior

[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"
    }
}
Set whether the handler uses autoflush or not
Use the write-attribute operation with the following syntax.
 /subsystem=logging/size-rotating-file-handler=HANDLER:write-attribute(name="autoflush", value="BOOLEAN") 
Replace HANDLER with the name of the log handler. Replace BOOLEAN with true if this handler is to immediately write its output.

Example 12.45. Set whether the handler uses autoflush or not

[standalone@localhost:9999 /] /subsystem=logging/size-rotating-file-handler=ACCOUNTS_TRACE:write-attribute(name="autoflush", value="true")
{"outcome" => "success"}
Set the encoding used for the handler's output
Use the write-attribute operation with the following syntax.
 /subsystem=logging/size-rotating-file-handler=HANDLER:write-attribute(name="encoding", value="ENCODING") 
Replace HANDLER with the name of the log handler. Replace ENCODING with the name of the required character encoding system.

Example 12.46. Set the encoding used for the handler's output

[standalone@localhost:9999 /] /subsystem=logging/size-rotating-file-handler=ACCOUNTS_TRACE:write-attribute(name="encoding", value="utf-8") 
{"outcome" => "success"}
Specify the file to which the log handler will write
Use the write-attribute operation with the following syntax.
 /subsystem=logging/size-rotating-file-handler=HANDLER:write-attribute(name="file", value={"path"=>"PATH", "relative-to"=>"DIR"}) 
Replace HANDLER with the name of the log handler. Replace PATH with the filename for the file that the log is being written to. Replace DIR with the name of the directory where the file is to be located. The value of DIR can be a path variable.

Example 12.47. Specify the file to which the log handler will write

[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"}
Set the formatter used for the handler's output
Use the write-attribute operation with the following syntax.
 /subsystem=logging/size-rotating-file-handler=HANDLER:write-attribute(name="formatter", value="FORMATTER") 
Replace HANDLER with the name of the log handler. Replace FORMAT with the required formatter string.

Example 12.48. Set the formatter used for the handler's output

[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"}
Set the maximum size of each log file
Use the write-attribute operation with the following syntax.
 /subsystem=logging/size-rotating-file-handler=HANDLER:write-attribute(name="rotate-size", value="SIZE") 
Replace HANDLER with the name of the log handler. Replace SIZE with maximum file size.

Example 12.49. Set the maximum size of each log file

[standalone@localhost:9999 /] /subsystem=logging/size-rotating-file-handler=ACCOUNTS_TRACE:write-attribute(name="rotate-size", value="50m")  
{"outcome" => "success"}
Set the maximum number of backup logs to keep
Use the write-attribute operation with the following syntax.
 /subsystem=logging/size-rotating-file-handler=HANDLER:write-attribute(name="max-backup-index", value="NUMBER") 
Replace HANDLER with the name of the log handler. Replace NUMBER with the required number of log files to keep.

Example 12.50. Set the maximum number of backup logs to keep

[standalone@localhost:9999 /] /subsystem=logging/size-rotating-file-handler=ACCOUNTS_TRACE:write-attribute(name="max-backup-index", value="5")
{"outcome" => "success"}
Set the rotate-on-boot option on the size-rotating-file-handler
This option is only available for the size-rotating-file-handler file handler. It defaults to false, meaning a new log file is not created on server restart.
To change it, use the write-attribute operation with the following syntax.
 /subsystem=logging/size-rotating-file-handler=HANDLER:write-attribute(name="rotate-on-boot", value="BOOLEAN") 
Replace HANDLER with the name of the size-rotating-file-handler log handler. Replace BOOLEAN with true if a new size-rotating-file-handler log file should be created on restart.

Example 12.51. Specify to create a new size-rotating-file-handler log file on server restart

[standalone@localhost:9999 /] /subsystem=logging/size-rotating-file-handler=ACCOUNTS_TRACE:write-attribute(name="rotate-on-boot", value="true")
{"outcome" => "success"}
Set the suffix for rotated logs
Use the write-attribute operation with the following syntax.
 /subsystem=logging/size-rotating-file-handler=HANDLER:write-attribute(name="suffix", value="SUFFIX") 
Replace HANDLER with the name of the log handler. Replace SUFFIX with the required suffix string.

Example 12.52. Set the suffix for rotated logs

[standalone@localhost:9999 /] /subsystem=logging/size-rotating-file-handler=ACCOUNTS_TRACE:write-attribute(name="suffix", value=".yyyy-MM-dd-HH")
{"outcome" => "success"}
Remove a log handler
Use the remove operation with the following syntax.
 /subsystem=logging/size-rotating-file-handler=HANDLER:remove 
Replace HANDLER with the name of the log handler.

Example 12.53. Remove a log handler

[standalone@localhost:9999 /] /subsystem=logging/size-rotating-file-handler=ACCOUNTS_TRACE:remove
{"outcome" => "success"}

12.3.7. Configure a Periodic Size Rotating Log Handler in the CLI

Periodic Size Rotating log handlers can be added, removed and edited in the CLI.
The main tasks you will perform to configure a periodic size rotating handler are:
  • Add a new periodic size rotating handler.
  • Display the configuration of a periodic size rotating handler.
  • Set the handler's log level.
  • Set the handler's appending behavior.
  • Set whether or not the handler uses autoflush.
  • Set the encoding used for the handler's output.
  • Specify the file to which the log handler will write.
  • Set the formatter used for the handler's output.
  • Set the maximum size of each log file.
  • Set the maximum number of backup logs to keep.
  • Set the rotate on boot option for the periodic size rotating handler.
  • Set the suffix for rotated logs.
  • Remove a periodic size rotating handler.
Each of those tasks are described below.

Important

When configuring a periodic size rotating handler in a logging profile for a standalone system, the root of the configuration path is /subsystem=logging/logging-profile=NAME/ instead of /subsystem=logging/.
For a managed domain, you must specify which profile to use. You must add the profile name to the beginning of the configuration path for a managed domain, replacing /subsystem=logging/ with /profile=NAME/subsystem=logging/.
Add a new Periodic Size Rotating handler
Use the add operation with the following syntax.
 /subsystem=logging/periodic-size-rotating-file-handler=HANDLER:add(file={"path"=>"PATH", "relative-to"=>"DIR"}) 
Replace HANDLER with the name of the log handler. Replace PATH with the filename for the file that the log is being written to. Replace DIR with the name of the directory where the file is to be located. The value of DIR can be a path variable.

Example 12.54. Add a new log handler

[standalone@localhost:9999 /] /subsystem=logging/periodic-size-rotating-file-handler=PERIODIC_SIZE:add(file={"path"=>"periodic_size.log","relative-to"=>"jboss.server.log.dir"},suffix=".yyyy.MM.dd")
{"outcome" => "success"}
Display the configuration of the log handler
Use the read-resource operation with the following syntax.
 /subsystem=logging/periodic-size-rotating-file-handler=HANDLER:read-resource 
Replace HANDLER with the name of the log handler.

Example 12.55. Display the configuration of the log handler

[standalone@localhost:9999 /] /subsystem=logging/periodic-size-rotating-file-handler=PERIODIC_SIZE:read-resource
{
    "outcome" => "success",
    "result" => {
        "append" => true,
        "autoflush" => true,
        "enabled" => true,
        "encoding" => undefined,
        "file" => {
            "relative-to" => "jboss.server.log.dir",
            "path" => "periodic_size.log"
        },
        "filter-spec" => undefined,
        "formatter" => "%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n",
        "level" => "ALL",
        "max-backup-index" => 1,
        "name" => "PERIODIC_SIZE",
        "named-formatter" => undefined,
        "rotate-on-boot" => false,
        "rotate-size" => "2m",
        "suffix" => ".yyyy.MM.dd"
    }
}
Set the handler's log level
Use the write-attribute operation with the following syntax.
 /subsystem=logging/periodic-size-rotating-file-handler=HANDLER:write-attribute(name="level", value="LOG_LEVEL_VALUE") 
Replace HANDLER with the name of the log handler. Replace LOG_LEVEL_VALUE with the log level that is to be set.

Example 12.56. Set the handler's log level

[standalone@localhost:9999 /] /subsystem=logging/periodic-size-rotating-file-handler=PERIODIC_SIZE:write-attribute(name="level", value="TRACE")
{"outcome" => "success"}
Set the handler's appending behavior
Use the write-attribute operation with the following syntax.
 /subsystem=logging/periodic-size-rotating-file-handler=HANDLER:write-attribute(name="append", value="BOOLEAN") 
Replace HANDLER with the name of the log handler. Replace BOOLEAN with false if you required that a new log file be created each time the application server is launched. Replace BOOLEAN with true if the application server should continue to use the same file.
JBoss EAP 6 must be restarted for this change to take effect.

Example 12.57. Set the handler's appending behavior

[standalone@localhost:9999 /] /subsystem=logging/periodic-size-rotating-file-handler=PERIODIC_SIZE:write-attribute(name="append", value="true")
{
    "outcome" => "success",
    "response-headers" => {
        "operation-requires-reload" => true,
        "process-state" => "reload-required"
    }
}
Set whether the handler uses autoflush or not
Use the write-attribute operation with the following syntax.
 /subsystem=logging/periodic-size-rotating-file-handler=HANDLER:write-attribute(name="autoflush", value="BOOLEAN") 
Replace HANDLER with the name of the log handler. Replace BOOLEAN with true if this handler is to immediately write its output.

Example 12.58. Set whether the handler uses autoflush or not

[standalone@localhost:9999 /] /subsystem=logging/periodic-size-rotating-file-handler=PERIODIC_SIZE:write-attribute(name="autoflush", value="true")
{"outcome" => "success"}
Set the encoding used for the handler's output
Use the write-attribute operation with the following syntax.
 /subsystem=logging/periodic-size-rotating-file-handler=HANDLER:write-attribute(name="encoding", value="ENCODING") 
Replace HANDLER with the name of the log handler. Replace ENCODING with the name of the required character encoding system.

Example 12.59. Set the encoding used for the handler's output

[standalone@localhost:9999 /] /subsystem=logging/periodic-size-rotating-file-handler=PERIODIC_SIZE:write-attribute(name="encoding", value="utf-8")
{"outcome" => "success"}
Specify the file to which the log handler will write
Use the write-attribute operation with the following syntax.
 /subsystem=logging/periodic-size-rotating-file-handler=HANDLER:write-attribute(name="file", value={"path"=>"PATH", "relative-to"=>"DIR"}) 
Replace HANDLER with the name of the log handler. Replace PATH with the filename for the file that the log is being written to. Replace DIR with the name of the directory where the file is to be located. The value of DIR can be a path variable.

Example 12.60. Specify the file to which the log handler will write

[standalone@localhost:9999 /] /subsystem=logging/periodic-size-rotating-file-handler=PERIODIC_SIZE:write-attribute(name="file", value={"path"=>"accounts_trace.log", "relative-to"=>"jboss.server.log.dir"})
{"outcome" => "success"}
Set the formatter used for the handler's output
Use the write-attribute operation with the following syntax.
 /subsystem=logging/periodic-size-rotating-file-handler=HANDLER:write-attribute(name="formatter", value="FORMAT") 
Replace HANDLER with the name of the log handler. Replace FORMAT with the required formatter string or name of the formatter as specified in the configuration file.

Example 12.61. Set the formatter used for the handler's output

[standalone@localhost:9999 /] /subsystem=logging/periodic-size-rotating-file-handler=PERIODIC_SIZE:write-attribute(name="formatter", value="%d{HH:mm:ss,SSS} %-5p (%c) [%t] %s%E%n")
{"outcome" => "success"}
Set the maximum size of each log file
Use the write-attribute operation with the following syntax.
 /subsystem=logging/periodic-size-rotating-file-handler=HANDLER:write-attribute(name="rotate-size", value="SIZE") 
Replace HANDLER with the name of the log handler. Replace SIZE with maximum file size.

Example 12.62. Set the maximum size of each log file

[standalone@localhost:9999 /] /subsystem=logging/periodic-size-rotating-file-handler=PERIODIC_SIZE:write-attribute(name="rotate-size", value="50m")  
{"outcome" => "success"}
Set the maximum number of backup logs to keep
Use the write-attribute operation with the following syntax.
 /subsystem=logging/periodic-size-rotating-file-handler=HANDLER:write-attribute(name="max-backup-index", value="NUMBER") 
Replace HANDLER with the name of the log handler. Replace NUMBER with the required number of log files to keep.

Example 12.63. Set the maximum number of backup logs to keep

[standalone@localhost:9999 /] /subsystem=logging/periodic-size-rotating-file-handler=PERIODIC_SIZE:write-attribute(name="max-backup-index", value="5")
{"outcome" => "success"}
Set the rotate-on-boot option on the periodic-size-rotating-file-handler
It defaults to false, meaning a new log file is not created on server restart.
To change it, use the write-attribute operation with the following syntax.
 /subsystem=logging/periodic-size-rotating-file-handler=HANDLER:write-attribute(name="rotate-on-boot", value="BOOLEAN") 
Replace HANDLER with the name of the periodic-size-rotating-file-handler log handler. Replace BOOLEAN with true if a new periodic-size-rotating-file-handler log file should be created on restart.

Example 12.64. Specify to create a new periodic-size-rotating-file-handler log file on server restart

[standalone@localhost:9999 /] /subsystem=logging/periodic-size-rotating-file-handler=PERIODIC_SIZE:write-attribute(name="rotate-on-boot", value="true")
{"outcome" => "success"}
Set the suffix for rotated logs
Use the write-attribute operation with the following syntax.
 /subsystem=logging/periodic-size-rotating-file-handler=HANDLER:write-attribute(name="suffix", value="SUFFIX") 
Replace HANDLER with the name of the log handler. Replace SUFFIX with the required suffix string.

Example 12.65. Set a suffix for rotated logs

[standalone@localhost:9999 /] /subsystem=logging/periodic-size-rotating-file-handler=PERIODIC_SIZE:write-attribute(name="suffix", value=".yyyy-MM-dd-HH")
{"outcome" => "success"}
Remove a log handler
Use the remove operation with the following syntax.
 /subsystem=logging/periodic-size-rotating-file-handler=HANDLER:remove 
Replace HANDLER with the name of the log handler.

Example 12.66. Remove a log handler

[standalone@localhost:9999 /] /subsystem=logging/periodic-size-rotating-file-handler=PERIODIC_SIZE:remove
{"outcome" => "success"}

12.3.8. Configure a Async Log Handler in the CLI

Async log handlers can be added, removed and edited in the CLI.
The tasks you will perform to configure an async log handler are:
  • Add a new async log handler
  • Display the configuration of an async log handler
  • Change the log level
  • Set the queue length
  • Set the overflow action
  • Add sub-handlers
  • Remove sub-handlers
  • Remove an async log handler
Each of these tasks are described below.

Important

When configuring a log handler in a logging profile for a standalone system, the root of the configuration path is /subsystem=logging/logging-profile=NAME/ instead of /subsystem=logging/.
For a managed domain, you must specify which profile to use. You must add the profile name to the beginning of the configuration path for a managed domain, replacing /subsystem=logging/ with /profile=NAME/subsystem=logging/.
Add a new async log handler
Use the add operation with the following syntax.
 /subsystem=logging/async-handler=HANDLER:add(queue-length="LENGTH") 
Replace HANDLER with the name of the log handler. Replace LENGTH with value of the maximum number of log requests that can be held in queue.

Example 12.67. Add a new async log handler

[standalone@localhost:9999 /] /subsystem=logging/async-handler=NFS_LOGS:add(queue-length="10")
{"outcome" => "success"}
Display the configuration of an async log handler
Use the read-resource operation with the following syntax.
 /subsystem=logging/async-handler=HANDLER:read-resource 
Replace HANDLER with the name of the log handler.

Example 12.68. Display the configuration of an async log handler

[standalone@localhost:9999 /] /subsystem=logging/async-handler=NFS_LOGS:read-resource
{
    "outcome" => "success",
    "result" => {
        "enabled" => true,
        "encoding" => undefined,
        "filter" => undefined,
        "filter-spec" => undefined,
        "formatter" => "%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n",
        "level" => "ALL",
        "name" => "NFS_LOGS",
        "overflow-action" => "BLOCK",
        "queue-length" => "10",
        "subhandlers" => undefined
    },
    "response-headers" => {"process-state" => "reload-required"}
}
Change the log level
Use the write-attribute operation with the following syntax.
 /subsystem=logging/async-handler=HANDLER:write-attribute(name="level", value="LOG_LEVEL_VALUE") 
Replace HANDLER with the name of the log handler. Replace LOG_LEVEL_VALUE with the log level that is to be set.

Example 12.69. Change the log level

[standalone@localhost:9999 /] /subsystem=logging/async-handler=NFS_LOGS:write-attribute(name="level", value="INFO")
{"outcome" => "success"}
Set the queue length
Use the write-attribute operation with the following syntax.
 /subsystem=logging/async-handler=HANDLER:write-attribute(name="queue-length", value="LENGTH") 
Replace HANDLER with the name of the log handler. Replace LENGTH with value of the maximum number of log requests that can be held in queue.
JBoss EAP 6 must be restarted for this change to take effect.

Example 12.70. Set the queue length

[standalone@localhost:9999 /] /subsystem=logging/async-handler=NFS_LOGS:write-attribute(name="queue-length", value="150")
{
    "outcome" => "success",
    "response-headers" => {
        "operation-requires-reload" => true,
        "process-state" => "reload-required"
    }
}
Set the overflow action
Use the write-attribute operation with the following syntax.
 /subsystem=logging/async-handler=HANDLER:write-attribute(name="overflow-action", value="ACTION") 
Replace HANDLER with the name of the log handler. Replace ACTION with either DISCARD or BLOCK.

Example 12.71. Set the overflow action

[standalone@localhost:9999 /] /subsystem=logging/async-handler=NFS_LOGS:write-attribute(name="overflow-action", value="DISCARD")
{"outcome" => "success"}
Add sub-handlers
Use the add-handler operation with the following syntax.
 /subsystem=logging/async-handler=HANDLER:add-handler(name="SUBHANDLER") 
Replace HANDLER with the name of the log handler. Replace SUBHANDLER with the name of the log handler that is to be added as a sub-handler of this async handler.

Example 12.72. Add sub-handlers

[standalone@localhost:9999 /] /subsystem=logging/async-handler=NFS_LOGS:add-handler(name="NFS_FILE")       
{"outcome" => "success"}
Remove sub-handlers
Use the remove-handler operation with the following syntax.
/subsystem=logging/async-handler=HANDLER:remove-handler(name="SUBHANDLER")
Replace HANDLER with the name of the log handler. Replace SUBHANDLER with the name of the sub-handler to remove.

Example 12.73. Remove sub-handlers

[standalone@localhost:9999 /] /subsystem=logging/async-handler=NFS_LOGS:remove-handler(name="NFS_FILE")       
{"outcome" => "success"}
Remove an async log handler
Use the remove operation with the following syntax.
/subsystem=logging/async-handler=HANDLER:remove 
Replace HANDLER with the name of the log handler.

Example 12.74. Remove an async log handler

[standalone@localhost:9999 /] /subsystem=logging/async-handler=NFS_LOGS:remove       
{"outcome" => "success"}

12.3.9. Configure a Custom Handler in the CLI

Custom handler can be added, removed, and edited in the CLI.
The main tasks you will perform to configure a custom handler are:
  • Add a new custom handler.
  • Display the configuration of a custom handler.
  • Set the log level.
  • Remove a custom handler.

Important

When configuring a custom handler in a logging profile for a standalone system, the root of the configuration path is /subsystem=logging/logging-profile=NAME/ instead of /subsystem=logging/.
For a managed domain, you must specify which profile to use. You must add the profile name to the beginning of the configuration path for a managed domain, replacing /subsystem=logging/ with /profile=NAME/subsystem=logging/.
Add a New Custom Handler
Use the add operation with the following syntax.
/subsystem=logging/custom-handler="MyCustomHandler":add

Example 12.75. Adding a new custom handler

[standalone@localhost:9999 /] /subsystem=logging/custom-handler="MyCustomHandler":add(class="JdbcLogger",module="com.MyModule",formatter="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n",properties={"maxNumberOfDays"=>"90","fileName"=>"custom.log","compressBackups"=>"true"})
Display Custom Handler
Use the read-resource operation with the following syntax. Replace CUSTOMHANDLER with the name of the custom handler.
/subsystem=logging/custom-handler=CUSTOMHANDLER:read-resource

Example 12.76. Display a custom handler configuration

[standalone@localhost:9999 /] /subsystem=logging/custom-handler="MyCustomHandler":read-resource
{
    "outcome" => "success",
    "result" => {
        "autoflush" => true,
        "enabled" => true,
        "encoding" => undefined,
        "filter" => undefined,
        "filter-spec" => undefined,
        "formatter" => "%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n",
        "level" => "INFO",
        "name" => "CONSOLE",
        "named-formatter" => "COLOR-PATTERN",
        "target" => "System.out"
    }
}
Set the Log Level
Use the write-attribute operation with the following syntax. Replace CUSTOMHANDLER with the name of the log category and LEVEL with the log level that is to be set.
/subsystem=logging/custom-handler=CUSTOMHANDLER:write-attribute(name="level", value="INFO") 

Example 12.77. Set the Log Level

[standalone@localhost:9999 /] /subsystem=logging/custom-handler="MyCustomHandler":write-attribute(name="level", value="TRACE")
{"outcome" => "success"}
Remove Custom Handler
Use the remove operation with the following syntax. Replace CUSTOMHANDLER with the name of the custom handler to be removed.
/subsystem=logging/custom-handler=CUSTOMHANDLER:remove

Example 12.78. Remove a custom handler

[standalone@localhost:9999 /] /subsystem=logging/custom-handler="MyCustomHandler":remove
{"outcome" => "success"}

12.3.10. Configure a Syslog Handler in the CLI

The log manager for JBoss EAP 6 now contains a syslog handler. Syslog handlers can be used to send messages to a remote logging server that supports the Syslog protocol (RFC-3164 or RFC-5424). This allows the log messages of multiple applications to be sent to the same server, where they can be parsed together. This topic covers how to create and configure a syslog handler using the Management CLI, and the available configuration options.
For details of syslog handler attributes see Section A.3, “Management Interface Audit Logging Reference”.

Prerequisites

  • Access and the correct permissions for the Management CLI.

Procedure 12.4. Add a Syslog Handler

  • Run the following command to add a syslog handler:
    /subsystem=logging/syslog-handler=HANDLER_NAME:add

Procedure 12.5. Configure a Syslog Handler

  • Run the following command to configure a syslog handler attribute:
    /subsystem=logging/syslog-handler=HANDLER_NAME:write-attribute(name=ATTRIBUTE_NAME,value=ATTRIBUTE_VALUE)

Procedure 12.6. Remove a Syslog Handler

  • Run the following command to remove an existing syslog handler:
    /subsystem=logging/syslog-handler=HANDLER_NAME:remove

12.3.11. Configure a Custom Log Formatter in the CLI

Summary

In addition to the log formatter syntax specified in Section 12.1.16, “Log Formatter Syntax”, a custom log formatter can be created for use with any log handler. This example procedure will demonstrate this by creating a XML formatter for a console log handler.

Prerequisites

  • Access to the Management CLI for the JBoss EAP 6 server.
  • A previously configured log handler. This example procedure uses a console log handler.

Procedure 12.7. Configure a Custom XML Formatter for a Log Handler

  1. Create custom formatter.
    In this example, the following command creates a custom formatter named XML_FORMATTER that uses the java.util.logging.XMLFormatter class.
    [standalone@localhost:9999 /] /subsystem=logging/custom-formatter=XML_FORMATTER:add(class=java.util.logging.XMLFormatter, module=org.jboss.logmanager)
  2. Register a custom formatter for the log handler you want to use it with.
    In this example, the formatter from the previous step is added to a console log handler.
    [standalone@localhost:9999 /] /subsystem=logging/console-handler=HANDLER:write-attribute(name=named-formatter, value=XML_FORMATTER)
  3. Restart the JBoss EAP 6 server for the change to take effect.
    [standalone@localhost:9999 /] shutdown --restart=true
Result

The custom XML formatter is added to the console log handler. Output to the console log will be formatted in XML, for example:

<record>
  <date>2014-03-11T13:02:53</date>
  <millis>1394539373833</millis>
  <sequence>116</sequence>
  <logger>org.jboss.as</logger>
  <level>INFO</level>
  <class>org.jboss.as.server.BootstrapListener</class>
  <method>logAdminConsole</method>
  <thread>282</thread>
  <message>JBAS015951: Admin console listening on http://%s:%d</message>
  <param>127.0.0.1</param>
  <param>9990</param>
</record>
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.