You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Mingfai <mi...@hongkong.com> on 2003/11/06 02:53:57 UTC

Re: [logging] Commons Logging with WebSphere

hi,

try to specify a system property as follows:

org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFac
toryImpl

In WSAD, there is an IBM log factory implementation:
com.ibm.ws.commons.logging.TrLogFactory by default. You may override it by
any ways such as using the above system properties or using PARENT_LAST in
class loader policy.

regards,
mingfai

----- Original Message ----- 
From: "Brian Lalor" <bl...@bravo5.org>
To: <co...@jakarta.apache.org>
Sent: Thursday, November 06, 2003 4:46 AM
Subject: Commons Logging with WebSphere


Good afternoon, all.  I'm attempting to use the Commons Logging API
with WebSphere Portal 5.0.  I'm getting a Log instance as shown in the
logging user's guide
private static Log log = LogFactory.getLog(CLASS.class);

This works fine in my development environment (WSAD on XP), but when I
try to deploy my portlet to a full-blown instance of Portal, my portlet
blows up.  The following is a snippet of the stack trace that occurs
when the portlet's being loaded.
biz.deltafaucet.contacts_list.ContactsListPortlet is my portlet:

[biz.deltafaucet.contacts_list.ContactsListPortlet]: Failed to load
servlet: java.lang.ExceptionInInitializerError:
org.apache.commons.logging.LogConfigurationException:
java.lang.ClassCastException: com.ibm.ws.commons.logging.TrLogFactory
at org.apache.commons.logging.LogFactory$2.run(LogFactory.java:609)
at java.security.AccessController.doPrivileged(Native Method)
at
org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:561)
at
org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:352)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:395)
at
biz.deltafaucet.contacts_list.ContactsListPortlet.<clinit>(ContactsListP
ortlet.java:45)
at java.lang.Class.newInstance0(Native Method)
at java.lang.Class.newInstance(Class.java(Compiled Code))
at java.beans.Beans.instantiate(Beans.java:233)

It looks like there may already be some of the commons logging
infrastructure built into WebSphere...

I'm assuming that I need to write a wrapper around the WebSphere
logging instance, but I'm hoping someone has already done that work.
:-)

Thanks,
B

--
    __   ____
   / /  / __/ Brian Lalor
  / _ \/__ \  blalor@bravo5.org
/_.__/____/  http://bravo5.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


RE: [logging] Commons Logging with WebSphere

Posted by Ming Fai <mi...@hongkong.com>.
> > try to specify a system property as follows:
> >
> > org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.L
> > ogFac
> > toryImpl
>
> I think I need to re-state my question.  I have no need (at the moment)
> for huge amounts of control over the logging facility.  I just want to
> be able to use a simple Log interface for logging debugging info.  I
> don't care where it comes from, and in the case of WSAD, I just want to
> tie into the provided logging infrastructure.  I'm hoping JCL can do
> that for me.

i personally think it's not a good idea to use the WSAD log factory. If you
want a very simple logging facility, use the JCL LogFactoryImpl and
SimpleLog
(-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog)
.

If you really want to save the effort of specifing two system properties,
lookup the WSAD document on how to use the WSAD logging. Afaik, the logging
is configured at:
	Your Server Configuration > Trace tab >
		check Enable Trace
	 	specify *=all=enable	(for enable all trace, or study the docs on how to
log by package/log level)
	The default ${SERVER_LOG_ROOT}/trace.log is located deeply under
.metadata/.plugins/xxx/ of your project folder.

>From the fact that the 2nd paragraph above seems to be more complex, it's a
better idea to use SimpleLog instead.


>
> > In WSAD, there is an IBM log factory implementation:
> > com.ibm.ws.commons.logging.TrLogFactory by default. You may override
> > it by
> > any ways such as using the above system properties or using
> > PARENT_LAST in
> > class loader policy.
>
> How do I get a logging instance from that factory using JCL?
>

There is nth special. Just get a logger from the default LogFactory as same
as using any common logger, for example:
	Log log = LogFactory.getLog(MyClass.class);
		log.info("this message is logged");
	see API doc:

http://jakarta.apache.org/commons/logging/api/org/apache/commons/logging/Log
Factory.html


regards,
mingfai



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [logging] Commons Logging with WebSphere

Posted by Brian Lalor <bl...@bravo5.org>.
On Nov 5, 2003, at 8:53 PM, Mingfai wrote:

> try to specify a system property as follows:
>
> org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.L 
> ogFac
> toryImpl

I think I need to re-state my question.  I have no need (at the moment)  
for huge amounts of control over the logging facility.  I just want to  
be able to use a simple Log interface for logging debugging info.  I  
don't care where it comes from, and in the case of WSAD, I just want to  
tie into the provided logging infrastructure.  I'm hoping JCL can do  
that for me.

> In WSAD, there is an IBM log factory implementation:
> com.ibm.ws.commons.logging.TrLogFactory by default. You may override  
> it by
> any ways such as using the above system properties or using  
> PARENT_LAST in
> class loader policy.

How do I get a logging instance from that factory using JCL?

Thanks for the quick response, Mingfai!
B

-- 
    __   ____
   / /  / __/ Brian Lalor
  / _ \/__ \  blalor@bravo5.org
/_.__/____/  http://bravo5.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org