BeeSoft®
Since 1992
 

Content

 Welcome
 Products
       Abeona
       Gaia
             News
             Documentation
                   Introduction
                   Swing support
                   Server application
                   Validation
                   XML
                   Logging
                   Utilities
                   Launcher
             License
             Download
       Hephaistos
       JavaGantt
 Services
       Promote your software
 Contact Us
 Links
      
  GaiaI®
© 2012 BeeSoft ®
 

Logging

Our logging package was created long in the past to ensure the independence of our applications from logging subsystem. It is just a facade before real logging system.

Programmer will work with an implementation of the interface eu.beesoft.gaoa.log.Log.

There are four logging levels:

  • DEBUG
  • INFO
  • WARNING
  • ERROR

For each level exist these methods:

  • isLevelEnabled()
  • level(String)
  • level(String, Throwable)
  • level(String, Object...)
where 'level' is used for one of 'debug', 'info', 'warn', 'error'.

Please note the last method: you can use it to merge any number of parameters to logged message. In these methods is each character pair {} replaced by one of the given parameters. For example you can log:

	info ("Current array index is {} of {}", 2, 5);

and logged message is Current array index is 2 of 5.

On the DEBUG level you can also use methods for logging of entering and exiting method.

The concrete implementation of Log interface can be obtained from LogFactory. It is an abstract superclass for all log factories. It serves as a factory of logger instances for different logging systems. Current factory can be obtained by LogFactory.getInstance() method. The typical usage scenario is like this:

	LogFactory factory = LogFactory.getInstance ();
	Log log = factory.getLog ("mypackage.MyClass");
	if (log.isDebugEnabled ()) {
		log.debug ("This is logged message");
}

This class also offers methods setThreadBoundIdentifier(String) and getThreadBoundIdentifier() to create link between current thread and an identifier defined by programmer. You can use them to log records with user name, for example. This is useful in server applications, where is difficult to pair a thread to the active client.

To customize this class to the requested logging system, you have to override createLog(String) method for your needs and to subclass the AbstractLog class. There are prepared implementations for:

  • Java (java.util.logging) system
  • Log4J (org.apache.log4j) system
  • Apache logging (org.apache.commons.logging) system

To use some of these logging systems you have to configure the underlaying real subsystem and create a corresponding factory by invoking its constructor (for example, for Log4J subsystem you need eu.beesoft.gaia.log.log4j.Log4jFactory instance). Then you can use the pattern from the introduction in your application.