Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 337624

Summary: [Discovery][ZooDiscovery] allow silencing of zookeeper startup, publish, shutdown
Product: [RT] ECF Reporter: Scott Lewis <slewis>
Component: ecf.discoveryAssignee: Wim Jongman <wim.jongman>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: P3    
Version: 3.5.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
mylyn/context/zip none

Description Scott Lewis CLA 2011-02-18 19:06:27 EST
Currently, when the zookeeper provider starts up and shuts down, it produces output to standard out...for example:

ZooDiscovery> Discovery Service Activated. Feb 18, 2011 3:53:38 PM. 
...
log4j:WARN No appenders could be found for logger (org.apache.zookeeper.server.ZooKeeperServer).
log4j:WARN Please initialize the log4j system properly.
ZooDiscovery> Service Published: Feb 18, 2011 3:53:42 PM. ServiceInfo[uri=ecf.osgirsvc://localhost:9278/osgirsvc_YFsonK7gMRipiNY7mhngPWce4X8=;id=ServiceID[type=ServiceTypeID[typeName=_ecf.osgirsvc._default.default._iana];location=ecf.osgirsvc://localhost:9278/osgirsvc_YFsonK7gMRipiNY7mhngPWce4X8=;full=_ecf.osgirsvc._default.default._iana@ecf.osgirsvc://localhost:9278/osgirsvc_YFsonK7gMRipiNY7mhngPWce4X8=];priority=0;weight=0;props=ServiceProperties[{endpoint.service.id=58, endpoint.package.version.org.eclipse.ecf.examples.remoteservices.hello=3.0.0, objectClass=org.eclipse.ecf.examples.remoteservices.hello.IHello, endpoint.framework.uuid=00c93b4b-ba3b-0010-1045-97c48d87b8f2, remote.intents.supported=passByValue exactlyOnce ordered, ecf.endpoint.id.ns=ecf.namespace.r_osgi, remote.configs.supported=ecf.r_osgi.peer, endpoint.id=r-osgi://localhost:9278, service.imported.configs=ecf.r_osgi.peer}]]
...
...
osgi> ZooDiscovery> Discovery Service Deactivated.Feb 18, 2011 3:57:27 PM. 

As well, the log4j initialization doesn't seem to be configured...i.e.

log4j:WARN No appenders could be found for logger (org.apache.zookeeper.server.ZooKeeperServer).
log4j:WARN Please initialize the log4j system properly.

Would it be possible to turn off the ZooDiscovery startup, publish, and shutdown output?  If desired, ECF has a trivial OSGi LogService implementation (SystemLogService)...as well as a LogHelper classes and others to use.  One example usage is here:

http://git.eclipse.org/c/ecf/org.eclipse.ecf.git/tree/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java

I'm not saying this LogService has to be used for addressing this bug, but it is available for use at no additional code cost and without additional dependencies.  Note also that the ECF util Trace class can also be used (for tracing/debug output).
Comment 1 Wim Jongman CLA 2011-02-20 11:38:11 EST
If an instance of the OSGi logservice is available, we use that. Otherwise we output to syso. Does the logservice you mention register itself as a service? 

With regards to zookeeper's internal logging: zookeeper uses log4j. It hooks into the users log4j environment. I am not at all familiar with all the stuff you need to do to get log4j up and running. I want to leave this up to the user and accept the WARN messages during ZK init.
Comment 2 Scott Lewis CLA 2011-02-20 11:45:03 EST
(In reply to comment #1)
> If an instance of the OSGi logservice is available, we use that. Otherwise we
> output to syso. Does the logservice you mention register itself as a service? 

No, ECF doesn't register org.eclipse.ecf.util.SystemLogService...since in environments like Eclipse ECF is not in a position to do that.  

Perhaps rather than using System.out directly in zookeeper if no OSGi logservice is available, perhaps just using the ECF equivalent...which is org.eclipse.ecf.util.SystemLogService.

> 
> With regards to zookeeper's internal logging: zookeeper uses log4j. It hooks
> into the users log4j environment. I am not at all familiar with all the stuff
> you need to do to get log4j up and running. I want to leave this up to the user
> and accept the WARN messages during ZK init.

I think there is some way to configure log4j to avoid these messages by default...i.e. for the zookeeper provider to configure log4j in the absence of other config, but I can't remember what it is.
Comment 3 Wim Jongman CLA 2011-02-20 12:16:24 EST
log4j bug moved to 337667
Comment 4 Wim Jongman CLA 2011-02-20 12:20:30 EST
Created attachment 189366 [details]
mylyn/context/zip
Comment 5 Wim Jongman CLA 2011-02-20 12:21:10 EST
Replaced syso with ECF's native logger. Changes pushed to master. FIXED.