• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

Logging in JBoss

Types of Logging

Log4j and logging services

Configuring logging

 

Configure logging service

Data logging is the process of recording events, with an automated computer program

JBoss AS uses log4j, an open source logging framework

Log4j is a tool to help the programmer output log statements to a variety of output targets.

Loggers may be assigned levels. The set of possible levels, that is:

TRACE

DEBUG

INFO

WARN

ERROR

FATAL

Features of log4j

log4j supports multiple output appenders per logger.

The format of the log output can be easily changed by extending the Layout class.

The target of the log output as well as the writing strategy can be altered by implementations of the Appender interface.

log4j is optimized for speed.

log4j is designed to handle Java Exceptions from the start.

TRACE<DEBUG

Log4J Pattern Layout

The PatternLayout, part of the standard log4j distribution, lets the user specify the output format according to conversion patterns similar to the C language printf function.

For example, the PatternLayout with the conversion pattern

“%r [%t] %-5p %c – %m%n”       will output something akin to:

176 [main] INFO org.foo.Bar – Located nearest gas station.

The first field is the number of milliseconds elapsed since the start of the program. The second field is the thread making the log request. The third field is the level of the log statement. The fourth field is the name of the logger associated with the log request. The text after the ‘-‘ is the message of the statement.

JBOSS – Logging service

JBossLogging

The log4j configuration file is located at server/xxx/conf/jboss-log4j.xml

By default, JBoss produces output to both the console and a log file (log/server.log).

These core tutorials will help you to learn 
the fundamentals of JBOSS.
For an in-depth understanding and practical experience, 
explore Online JBOSS Training.

By default, The logging threshold for the console is INFO, For server.log no          threshold

By default, The server.log file is created new each time the server is launched, and grows until the server is stopped or until midnight Listing shows how you can change the Appender for the server.log file to create, atmost, 20 log files of 10 MB in size each.

JBOSS – Application specific log

 

JBossApplicationLogging

As another example, let’s say you wanted to set the output from the container-managed persistence engine to DEBUG level and to redirect it to a separate file, cmp.log, in order to analyze the generated SQL commands. You would add the following code to the conf/jboss-log4j.xml file:

This creates a new file appender and specifies that it should be used by the logger (or category) for the package org.jboss.ejb.plugins.cmp.

The file appender is set up to produce a new log file every day rather than producing a new one every time you restart the server or writing to a single file indefinitely. The current log file is cmp.log. Older files have the date they were written added to their filenames.

For indepth understanding on JBoss click on:

Summary
Review Date
Reviewed Item
Logging in JBoss
Author Rating
5

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on Logging in JBoss"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Site Disclaimer, Copyright © 2016 - All Rights Reserved.

    Support


    Please leave a message and we'll get back to you soon.

    I agree to be contacted via e-mail.