Logging

Top  Previous  Next

This snippet shows you how to add logging to any java application.

 

If you set the console level to TRACE, you will pickup the domain object, mapping and connection pool logging that is part of any domain object model that you generate.

 

import com.wickedfastsolutions.commons.log.component.api.*;
 
public class Application
{
    public static void main(final String[] args) throws Exception
    {
        startLogger();
        
        Log.debug("Hello World!");    
 
        stopLogger();
    }
    
    private static void startLogger() throws Exception
    {
        final LogProperties logProperties = com.wickedfastsolutions.commons.log.component.api.ObjectFactory.createLogProperties();
        
        logProperties.setConsoleLevel(ConsoleLevel.TRACE);
        
        com.wickedfastsolutions.commons.log.component.api.ObjectFactory.registerLogger(logProperties);    
    }
    
    private static void stopLogger()
    {        
        com.wickedfastsolutions.commons.log.component.api.ObjectFactory.unregisterLogger();
        
        try
        {
            Thread.sleep(2000);
        }
        catch (final Exception ex)
        {
        }
    }
}