View RSS Feed

Commons Lang

  1. Log4J Logging Exceptions

    by , 02-24-2012 at 08:27 PM
    Usually it has been seen that user don’t stay bound to follow the rules. Therefore it is general rule to deal, with exceptions. Different exceptions would be discussed in this post which are based upon those boundaries which are crossed by them.
    • External Boundaries /Expected Exceptions: Example of this exception is FileNotFoundException. API boundries are crossed by it and gets exposed to users. Such kind of exceptions are enlisted in clause “throws”.They shall be handled with proper
    Commons Lang
  2. Log4J Message Priorities/Levels

    by , 02-24-2012 at 08:26 PM
    Levels and priorities for the messages are supported by logging. Content severity shall be made sure. Use these guidelines to describe the messages severity.

    • fatal – Severe kind of errors which would result into premature termination. Expect them to be visible instantly at the status console. Internationalization shall also be seen.
    • error - Other unexpected conditions or runtime errors. Expect them to be visible immediately at the status console.
    • warn - Depreciated APIs usage,
  3. Jars Included in the Standard Log4J Distribution

    by , 02-24-2012 at 08:24 PM
    Standard distribution includes these jars.
    • commons-logging.jar: Following are included in the commons-logging.jar

    o Java commons logging API
    o For Log4J, thin wrapper Log implementations
    o LogFactory implementations

    • commons-logging-api.jar: Java Commons Logging API, built-in Log simpleLog implementations & LogFactory implementation are included.

    • Commons-logging-adapters.jar: Adapters are included in it to 3rd part log
    Tags: log4j jars Add / Edit Tags
    Commons Lang
  4. Logging a Message

    by , 02-24-2012 at 08:21 PM
    To a logger, all messages get logged. Such messages logging is dependent at the methods which correspond to the priority. The interface org.apache.commons.logging.Log details these methods to be used for writing log.
    Java Code:
        log.fatal(Object message);
        log.fatal(Object message, Throwable t);
        log.error(Object message);
        log.error(Object message, Throwable t);
        log.warn(Object message);
        log.warn(Object message, Throwable t);
    Commons Lang
  5. Obtaining a Log Object

    by , 02-24-2012 at 08:19 PM
    For using the Java Common Logging SPI, use these import statements in Java class file.
    Java Code:
    import org.apache.commons.logging.Log; 
    import org.apache.commons.logging.LogFactory;
    It shall be noted that few components which use JCL might extend the Log or may be able to give “component specific” LogFactory implementation. Initialize & declare log attributes for each class definition, as following:

    Java Code:
    public class CLASS
    Tags: log object Add / Edit Tags
    Commons Lang
  6. Configuring Log4J

    by , 02-24-2012 at 08:17 PM
    Log4J is considered to be the most frequently used library, for logging. Log4J present in your application has integration details which will be discussed in this section. A property file and system properties are used to configure Log4J.

    This system property is used for specification of the Log4J configuration file naming. Default configuration file would be, in case it is not specified.

    • log4j.rootCategory=priority
    Commons Lang
  7. Configuring the Underlying Logging System

    by , 02-24-2012 at 08:14 PM
    Java Commons Logging SPI shall be configured for using logging toolkits. A bridge is provided by the Commons Logging to write log messages. Message logging is only supported by it and no API configuration is supported for the logging system.

    Java Commons Logging configuration is dependent upon logging toolkit. Java Commons Logging doesn’t hold responsibility for:

    • Underlying library initialization.
    • Underlying library configuration.
    • Underlying library shutdown.
    Commons Lang
  8. Java Commons Logging Configuration

    by , 02-24-2012 at 08:13 PM
    Java Commons Logging uses these base abstractions.

    • Log- the basic logger
    • LogFactory i.e. How a Log instances is created

    A specific log implemenatation specification is quite useful. LogFactory implementation is specified by the advanced users. These discovery processes are used by the default LogFactory implementations.

    • The org.apache.commons.logging.Log attribute shall be looked for. Java code can be used for setting these attributes. Properties ...
  9. The Logging Component

    by , 02-24-2012 at 08:11 PM
    Logging information is very important while a library is written. Numbers of logging implementations are there in market. A specified logging library usage cant be imposed by a library at the application.

    Logging package is considered to be an ultra thing bridge among various logging implementations. Library using common logging APIs might be used along with some logging implementations, at the run time. Commons logging provides support for different logging implementations. For others, ...
    Commons Lang