[ 
https://issues.apache.org/jira/browse/KARAF-3173?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14106937#comment-14106937
 ] 

Matt Sicker commented on KARAF-3173:
------------------------------------

I can't share the exact code we're using, but I can provide analogous code. The 
basic gist of what I'm doing is:

# I've got a class that contains a Logger obtained from LoggerFactory as usual.
# That class is managed in a blueprint container.
# That bean is used in a Camel route through the [bean 
component|http://camel.apache.org/bean.html] as an endpoint URI (there are two 
different implementation beans of the same interface/strategy which is invoked 
through a recipient list).

So, essentially, I've got:

{code}
public class BusinessIllogicBean {
  private static final Logger LOGGER = 
LoggerFactory.getLogger(BusinessIllogicBean.class);

  private DataSource dataSource;
  public DataSource getDataSource() { return dataSource; }
  public void setDataSource(final DataSource dataSource) { this.dataSource = 
dataSource; }

  @Handler
  public String normalizeUserId( @Header("userId") final String userId ) {
    LOGGER.debug("Normalizing user id [{}]", userId);
    return StringUtils.toUpperCase(userId);
  }
}
{code}

Blueprint:

{code}
<blueprint>
  <reference id="ds" interface="javax.sql.DataSource"/>
  <bean id="business" class="com.foo.BusinessIllogicBean">
    <property name="dataSource" ref="ds"/>
  </bean>
  <camelContext>
    <contextScan/>
  </camelContext>
</blueprint>
{code}

And the Camel route:

{code}
public class BusinessRoute extends RouteBuilder {
  @Override
  protected void configure() throws Exception {
    from("direct:foo").recipientList().simple("bean:${header.beanName}");
  }
}
{code}

Nothing gets logged. Same general manifest headers as I explained in the 
summary.

> Using SLF4J does not log anything
> ---------------------------------
>
>                 Key: KARAF-3173
>                 URL: https://issues.apache.org/jira/browse/KARAF-3173
>             Project: Karaf
>          Issue Type: Bug
>          Components: karaf-core
>    Affects Versions: 3.0.1
>            Reporter: Matt Sicker
>              Labels: logging, slf4j
>
> Here's the relevant parts of my {{org.ops4j.pax.logging.cfg}} file:
> {code}
> # File appender
> log4j.appender.out=org.apache.log4j.RollingFileAppender
> log4j.appender.out.layout=org.apache.log4j.PatternLayout
> log4j.appender.out.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t 
> | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n
> log4j.appender.out.file=${karaf.data}/log/karaf.log
> log4j.appender.out.append=true
> log4j.appender.out.maxFileSize=1MB
> log4j.appender.out.maxBackupIndex=10
> log4j.logger.com.peapod=DEBUG, out
> {code}
> Then, inside a bundle class, I have a private static final Logger from SLF4J. 
> Doing the following won't log anything anywhere:
> {code}
> LOGGER.debug("Hello, world!");
> LOGGER.error("Not even this!");
> {code}
> Viewing the headers of my bundle show the following in the Import-Package 
> attribute:
> {code}
> org.slf4j;version="[1.7,2)"
> {code}
> For the Pax logging API bundle, it has the following in its Export-Package 
> attribute:
> {code}
> org.slf4j;uses:="org.slf4j.helpers,org.slf4j.spi";provider=paxlogging;version=1.7.1
> {code}
> The only way I've been able to log anything whatsoever has been to inject the 
> OSGi LogService which shouldn't be required. I'm using OPS4J Pax Logging 
> version 1.7.2 if that helps (the 1.7.1 is for SLF4J apparently).



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to