You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Nicolas Peltier <np...@adobe.com.INVALID> on 2017/06/22 11:08:23 UTC

Re: Programmatically create a logger

Hi Chetan,

Good catch indeed! Specifying the location did the trick. 

Now I’m on the next issue :-) once configured, it looks that there is some gap before output switch is done from default logger to the specified logger.

log.info(“before”);
config.update(...)
log.info(“after”);
…
log.info(“long after”);

Will only show “long after” and after that one. Worse, there are logs “in the middle” that are lost (not on the default logger, nor on the configured one). Is there a trick for a flush/wait that would help?

(Btw is there a way I can unit test those outputs at all?)

Nicolas
> On 23 May 2017, at 05:55, Chetan Mehrotra <ch...@gmail.com> wrote:
> 
> On Fri, May 19, 2017 at 9:38 PM, Nicolas Peltier
> <np...@adobe.com.invalid> wrote:
>> org.osgi.service.cm.Configuration.update(dict) from sling pipes bundle does not trigger LoggerManagedServiceFactory.updated
> 
> How are you creating the config instance from ConfigurationAdmin
> instance? You should use the listConfiguration approach [1] otherwise
> the config instance would get "bound" to the calling bundle [2] which
> would prevent that config from getting used by the Commons Log bundle
> 
> 
> Chetan Mehrotra
> [1] https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fapache%2Fsling%2Fblob%2Ftrunk%2Finstaller%2Ffactories%2Fconfiguration%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fsling%2Finstaller%2Ffactories%2Fconfiguration%2Fimpl%2FConfigUtil.java%23L191&data=02%7C01%7C%7C9373bf816b1c4c223e1408d4a18fa0df%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636311085627988743&sdata=vKgCoaYjNYdTfXjSOk12Hg1R5tHFshf0h4gqXTM%2Fb84%3D&reserved=0
> [2] https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fosgi.org%2Fjavadoc%2Fr4v42%2Forg%2Fosgi%2Fservice%2Fcm%2FConfigurationAdmin.html%23getConfiguration(java.lang.String&data=02%7C01%7C%7C9373bf816b1c4c223e1408d4a18fa0df%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636311085627988743&sdata=WHxtsSoaDuBR21lgq2E9HEyCQJmkduy%2BfTneSVh0oLI%3D&reserved=0)