Configure the logging subsystem in a JBoss EAP managed domain, and deploy the kitchensink application to test the configuration.
| Resources | |
|---|---|
| Files |
/opt/domain
/var/log/jboss
|
| Application URL |
http://172.25.250.10:8080/kitchensink
http://172.25.250.11:8080/kitchensink
|
Outcomes
You should be able to configure the logging subsystem of a JBoss EAP managed domain and deploy the kitchensink application to verify that application logs are generated.
Use the following command to prepare the environment:
[student@workstation ~]$ lab start logging-review
A JBoss EAP administrator has set up a managed domain with two host controllers running on servera and serverb machines.
The domain controller runs on the workstation machine.
The domain and host configuration files are stored in the /opt/domain directory on all three machines.
![]() |
You must start the managed domain and configure the logging subsystem of the full profile in the managed domain.
To verify that applications in the managed domain print logs to the right location you must deploy the kitchensink application.
Instructions
Start the domain controller.
Use /opt/domain as the jboss.domain.base.dir value.
The host file for the domain controller is called host-master.xml.
Note that the jboss user owns the /opt/domain directory.
Therefore, you must start the domain controller by using the jboss user.
Start the host controllers on the servera and the serverb machines.
Use /opt/domain as the jboss.domain.base.dir value.
The host file for the host controllers is host-slave.xml.
Note that the jboss user owns the /opt/domain directory.
Therefore, you must start the host controller by using the jboss user.
You can safely ignore the following output:
WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.wildfly.extension.elytron.SSLDefinitions (jar:file:/opt/jboss-eap-7.4/modules/system/layers/base/.overlays/layer-base-jboss-eap-7.4.11.CP/org/wildfly/extension/elytron/main/wildfly-elytron-integration-15.0.26.Final-redhat-00001.jar!/) to method com.sun.net.ssl.internal.ssl.Provider.isFIPS() WARNING: Please consider reporting this to the maintainers of org.wildfly.extension.elytron.SSLDefinitions WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release
For more information, refer to https://access.redhat.com/solutions/4996491.
Start the host controller on the servera machine.
Start the host controller on the serverb machine.
Verify that both host controllers connect to the domain controller and form a managed domain.
Inspect the console window where you started the domain controller and verify that both servera and serverb are registered as secondary controllers.
[Host Controller] 03:28:53,434 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: JBoss EAP 7.4.11.GA (WildFly Core 15.0.26.Final-redhat-00001) (Host Controller) started in 3622ms - Started 80 of 81 services (22 services are lazy, passive or on-demand) [Host Controller] 03:29:12,302 INFO [org.jboss.as.domain.controller] (Host Controller Service Threads - 37)WFLYHC0019: Registered remote slave host "servera", JBoss JBoss EAP 7.4.11.GA (WildFly 15.0.26.Final-redhat-00001) [Host Controller] 03:29:47,951 INFO [org.jboss.as.domain.controller] (Host Controller Service Threads - 37)WFLYHC0019: Registered remote slave host "serverb", JBoss JBoss EAP 7.4.11.GA (WildFly 15.0.26.Final-redhat-00001)
Create a size-rotating-file-handler handler and associate it with the org.jboss.as.quickstarts package from the kitchensink application.
A size-rotating-file-handler accepts a relative-path value and a file name as input.
Usually, the relative paths point to the log directory under the JBoss EAP base directory.
In this lab, you need to change this relative-path value to point to the /var/log/jboss directory.
A path variable references a file system path.
In a new terminal window on the workstation, start the management CLI and connect to the domain controller as the jboss user:
Create a path variable called custom.log.dir with the /var/log/jboss value.
In the JBoss EAP management console, this can be done in the → section.
[student@workstation ~]$ sudo -u jboss /opt/jboss-eap-7.4/bin/jboss-cli.sh \
--connect --controller=172.25.250.9:9990
[domain@172.25.250.9:9990 /][domain@172.25.250.9:9990 /] /path=custom.log.dir:add(path=/var/log/jboss/)
{
"outcome" => "success",
"result" => undefined,
"server-groups" => {
"Group1" => {"host" => {
"servera" => {"servera.1" => {"response" => {
"outcome" => "success",
"result" => undefined
}}},
"serverb" => {"serverb.1" => {"response" => {
"outcome" => "success",
"result" => undefined
}}}
}},
"Group2" => {"host" => {
"servera" => {"servera.2" => {"response" => {
"outcome" => "success",
"result" => undefined
}}},
"serverb" => {"serverb.2" => {"response" => {
"outcome" => "success",
"result" => undefined
}}}
}}
}
}After you have defined a new path variable, you can refer to it when creating handlers.
Create a size-rotating-file-handler in the full profile called kitchensink_LOG_HANDLER with the following configuration:
| Field | Value |
|---|---|
| Profile |
full
|
| Name |
kitchensink_LOG_HANDLER
|
| Path (name of log file) |
${jboss.server.name}/kitchensink.log
|
| Relative To (relative path variable) |
custom.log.dir
|
| Append, Autoflush, Enabled | Enable all these attributes (if using the CLI, set to 'true') |
| Level |
DEBUG
|
| Rotate Size |
1m (1 MB)
|
| Max Backup Index |
5
|
[domain@172.25.250.9:9990 /] /profile=full/subsystem=logging/\
size-rotating-file-handler=kitchensink_LOG_HANDLER:add\
(file={"relative-to"=>"custom.log.dir",\
"path"=>"${jboss.server.name}/kitchensink.log"}, \
enabled=true, append=true, autoflush=true,\
rotate-size=1m, max-backup-index=5,\
level=DEBUG)
{
"outcome" => "success",
...output omitted...
}Verify the previous handler by using either the management console or the management CLI.
[domain@172.25.250.9:9990 /]/profile=full/subsystem=logging\ /size-rotating-file-handler=kitchensink_LOG_HANDLER:read-resource{ "outcome" => "success", "result" => {"append" => true, "autoflush" => true, "enabled" => true,"encoding" => undefined,"file" => { "relative-to" => "custom.log.dir", "path" => expression "${jboss.server.name}/kitchensink.log" },"filter" => undefined, "filter-spec" => undefined, "formatter" => "%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n","level" => "DEBUG", "max-backup-index" => 5,"name" => "kitchensink_LOG_HANDLER", "named-formatter" => undefined, "rotate-on-boot" => false,"rotate-size" => "1m","suffix" => undefined } }
Set the ROOT logger to the WARNING level and configure a specific logging level for the kitchensink application.
Create a logger category called org.jboss.as.quickstarts set to DEBUG level by default, which is the package hierarchy for the kitchensink application.
Associate this logger with the kitchensink_LOG_HANDLER to have kitchensink related log messages show up in the kitchensink.log file.
Change the ROOT logger level to WARN.
Deploy the kitchensink application.
Verify that Group1 server group has the kithensink application running on servera.1 and serverb.1 machines.
Observe the console window of servera and serverb for any error messages or warnings.
Because you set the ROOT logger to WARN level, you should only see WARN and ERROR level messages in the console window of servera and serverb.
Use the management CLI to deploy the /tmp/kitchensink.war file to the Group1 server group.
Verify that you can access the kitchensink application at http://172.25.250.10:8080/kitchensink and http://172.25.250.11:8080/kitchensink.
Access the application on both URLs and refresh the page several times to produce log output.
Verify that you can view the logs for the kitchensink application under the /var/log/jboss/servera.1 directory on servera.
[student@workstation ~]$ssh jboss@servera tail \ /var/log/jboss/servera.1/kitchensink.log...output omitted... 10:38:55,602INFO[...MemberListProducer] (default task-1) Retrieving member list. 10:38:55,602DEBUG[...MemberListProducer] (default task-1) Returning: John Smith, john.smith@mailinator.com
Verify that you can view the logs for the kitchensink application under the /var/log/jboss/serverb.1 directory on serverb.
[student@workstation ~]$ ssh jboss@serverb tail \
/var/log/jboss/serverb.1/kitchensink.log
...output omitted...
0:40:26,327 INFO [...MemberListProducer] (default task-1) Retrieving member list.
10:40:26,327 DEBUG [...MemberListProducer] (default task-1) Returning: John Smith, john.smith@mailinator.comUsing either the administration console or the management CLI, undeploy the kitchensink application.
Clean up.
Press Ctrl+C to stop the management CLI and the domain and host controllers.