[seek-dev] changing ecogrid server side to use commons-logging.

Matthew Brooke brooke at nceas.ucsb.edu
Wed Sep 7 14:11:20 PDT 2005


Jing -

The beauty of log4j is that the output can be formatted to include lots 
of information about the specific class and method that is writing to 
the log, which also allows you to filter the logging by class name or 
package name, as well as level of severity.

If you just replace the call in EcogridUtil.debugMessage with a central 
call to log4j, you will lose this information.

m




Jing Tao wrote:
> Hi, Kevin:
> 
> It seems good plan to use commons-loggin/log4j infrastructure. But I have 
> a suggestion: rather than change every "EcogridUtils.debugMessage" to
> "logger.debug", we can modify EcogridUtil.debugMessage directly. Currently 
> EcogridUtil.debugMessage use System.err.println and we can change to use 
> the commons-loggin/log4j.
> 
> How do you think this apporach?
> 
> Thanks,
> 
> Jing
> 
> Jing Tao
> National Center for Ecological
> Analysis and Synthesis (NCEAS)
> 735 State St. Suite 204
> Santa Barbara, CA 93101
> 
> On Wed, 7 Sep 2005, Kevin Ruland wrote:
> 
> 
>>Date: Wed, 07 Sep 2005 14:12:12 -0500
>>From: Kevin Ruland <kruland at ku.edu>
>>To: seek-dev at ecoinformatics.org
>>Subject: [seek-dev] changing ecogrid server side to use commons-logging.
>>
>>
>>Jing,
>>
>>Globus grid services use commons-logging/log4j infrastructure for all
>>its output.  I decided to make the Digir implementation follow these
>>lines because it allows easier configuration of log messages.  Matt
>>suggested it we should try to move all the ecogrid server code to using
>>this logging mechanism.  Allow me the chance to highlight the changes
>>needed for this.
>>
>>Where before in DigirProxyImpl, it would do this:
>>
>>import org.ecoinformatics.ecogrid.EcogridUtils;
>>
>>public class DigirProxyImpl implements
>>EcoGridQueryInterfaceLevelOnePortType {
>>
>>public DigirProxyImpl()
>>{
>> EcogridUtils.setDebug(true);
>> EcogridUtils.debugMessage( "DigirProxyImpl Constructor", 1 );
>>}
>>}
>>
>>
>>It now looks like this:
>>
>>import org.apache.commons.logging.Log;
>>import org.apache.commons.logging.LogFactory;
>>
>>public class DigirProxyImpl implements
>>EcoGridQueryInterfaceLevelOnePortType {
>>   static Log logger  = LogFactory.getLog( DigirProxyImpl.class.getName());
>>
>> public DigirProxyImpl()
>> {
>>   if (Logger.isDebugEnabled()) {
>>    logger.debug("DigirProxyImpl Constructor" );
>>  }
>> }
>>}
>>
>>In reality the test for isDebugEnabled() is not required, but it does
>>provide performance improvement if the message arguments are expensive
>>to construct.  In this example, it would read much better without it.
>>
>>In order to enable logging in the deployed server, you need to correct
>>one problem that ogsa's ant deployTomcat introduces.  You need to mv
>>webapps/ogsa/WEB-INF/ogsilogging.properties to
>>webapps/ogsa/WEB-INF/classes/ogsilogging.properties.  I corrected the
>>globus build-services.xml to copy it into the correct location to begin
>>with.
>>
>>Now in order to enable debug level for your class you need to insert a
>>line in the ogsilogging.properties:
>>
>>org.ecoinformatics.ecogrid.digir.impl.DigirProxyImpl=console,debug
>>
>>All the log messages sent to console end up in catalina.out.  There
>>should be a way to configure the logging properties to redirect to a
>>different file, but I haven't needed to so didn't look for the answer.
>>
>>Kevin
>>_______________________________________________
>>Seek-dev mailing list
>>Seek-dev at ecoinformatics.org
>>http://mercury.nceas.ucsb.edu/ecoinformatics/mailman/listinfo/seek-dev
>>
> 
> _______________________________________________
> Seek-dev mailing list
> Seek-dev at ecoinformatics.org
> http://mercury.nceas.ucsb.edu/ecoinformatics/mailman/listinfo/seek-dev

-- 

-------------------------------------------------------------
Matthew Brooke, Ph.D.                User Interface Developer
Marine Sciences Research Building, Room #3407
University of California
Santa Barbara, CA  93106-6150
ph: (805) 893-7108   fx: 805-893-8062   brooke at nceas.ucsb.edu
-------------------------------------------------------------


More information about the Seek-dev mailing list