- Lab
- A Cloud Guru
Configuring a Logging Profile in JBoss EAP
JBoss Enterprise Application Platform allows us to do more than simply deploy applications — we can also manage and maintain them during their lifecycle. Part of this is the ability to log what we need when we need it, which is where JBoss EAP logging profiles come in. Logging profiles allow us to write customized logging rules that we then attach to our applications as desired.
Path Info
Table of Contents
-
Challenge
Create the Logging Profile
- Access the JBoss EAP CLI:
cd /opt/jboss-eap/ sudo ./bin/jboss-cli.sh connect
- Create the
appdebug
logging profile:
/subsystem=logging/logging-profile=appdebug:add
-
Challenge
Create the File Handler
- Create the file handler:
/subsystem=logging/logging-profile=appdebug/file-handler=appdebug-handler:add(file={path=>"debug.log", "relative-to"=>"jboss.server.log.dir"})
- Set the log level for the handler:
/subsystem=logging/logging-profile=appdebug/file-handler=appdebug-handler:write-attribute(name="level", value="TRACE")
-
Challenge
Create a Logger Category
- Add the logger category:
/subsystem=logging/logging-profile=appdebug/logger=app.debug:add(level=DEBUG)
- Assign the handler to the category:
/subsystem=logging/logging-profile=appdebug/logger=org.hibernate:add-handler(name="appdebug-handler")
-
Challenge
Set Logs to Format as JSON
Ensure the logs will be formatted as JSON:
/subsystem=logging/logging-profile=appdebug/json-formatter=NAME:add(pretty-print=true, exception-output-type=formatted)
-
Challenge
Add the Logger Profile to the Application
- Exit the CLI:
exit
- Move into
/home/cloud_user/kitchensink
:
cd ~/kitchensink
- Add a
MANIFEST.MF
file to the application:
vim src/main/resources/META-INF/MANIFEST.MF Manifest-Version: 1.0 Logging-Profile: appdebug
- Deploy the application:
sudo mvn clean install wildfly:deploy
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.