Use this: cs.getConfiguration("org.ops4j.pax.logging",null);

Another, simpler, way is to set the framework property
org.ops4j.pax.logging.DefaultServiceLog.level=INFO

You can do that in pax exam like this:
http://paxexam.ops4j.org/display/paxexam/Core+configuration+options#Coreconfigurationoptions-Settingupsystemproperties

HTH,

On Fri, Dec 4, 2009 at 10:49 PM, Kris Pruden <kpru...@gmail.com> wrote:

> Hi,
>
> I'm using pax:exam and I'm trying to use the 'log' profile to provision
> pax:logging as the log provider.  That all works fine, except it seems to
> default to a log level of DEBUG and I can't figure out how to change it.
>
> I have a log4j.properties file included in my classpath, and pax:exam seems
> to be respecting this while it's working through the provisioning/setup
> process, but once the child java process is forked to run the actual OSGi
> container (felix in my case) and run the tests, the logging configuration
> isn't making it across and I'm getting a TON of output.
>
> I tried manually updating the logging configuration in code via
> ConfigurationAdmin, as described in the pax:logging documentation, but that
> doesn't seem to work.  Here's the code:
>
> private void initLogging() {
>        ServiceReference ref =
> context.getServiceReference(ConfigurationAdmin.class.getName());
>        ConfigurationAdmin cs = (ConfigurationAdmin)
> context.getService(ref);
>
>        org.osgi.service.cm.Configuration conf =
> cs.getConfiguration("org.ops4j.pax.logging");
>        Dictionary<Object, Object> props = conf.getProperties();
>        if (props == null) {
>                props = new Properties();
>        }
>
>        props.put("log4j.rootCategory", "WARN, stdout");
>        props.put("log4j.appender.stdout",
> "org.apache.log4j.ConsoleAppender");
>        props.put("log4j.appender.stdout.layout.ConversionPattern",
> "[%30.30c{1}] - %m%n");
>        props.put("log4j.appender.stdout.layout",
> "org.apache.log4j.PatternLayout");
>
>        conf.update(props);
> }
>
> Even with this code, I'm still seeing all the debug output.
>
> What am I doing wrong?
>
> Thanks,
>
> Kris
>
> _______________________________________________
> general mailing list
> general@lists.ops4j.org
> http://lists.ops4j.org/mailman/listinfo/general
>



-- 
Alin Dreghiciu
Software Developer
My profile: http://www.linkedin.com/in/alindreghiciu
My blog: http://adreghiciu.wordpress.com
http://sonatype.com - Sonatype - The Maven Company
http://www.ops4j.org - New Energy for OSS Communities - Open Participation
Software.
http://www.qi4j.org - New Energy for Java - Domain Driven Development.
_______________________________________________
general mailing list
general@lists.ops4j.org
http://lists.ops4j.org/mailman/listinfo/general

Reply via email to