0

I am using slf4j & logback for logging and my application is deployed in Apache Service Mix where other modules are using my logging service. Everything works fine when i test it in a standalone environment but i face problem when i deploy it in a service mix container. At that time, only root level logging is effective and other logging levels are ignored.

Below is my logback-test.xml configuration, Kindly help i am stuck in this issue for the last 4 days.

<!-- This property describes the location of the property file. -->
<property
    file="C:/Users/evikdew/ccl_code/log.properties" />

<!-- This appender prints on the console. -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
        <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
        </pattern>
    </encoder>
</appender>

<!-- This appender contains the properties for the logs that would be written 
    to a file. -->
<appender name="FILE"
    class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${LOG_DIRECTORY}\${LOG_FILE_NAME}</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <fileNamePattern>${LOG_FILE_PATTERN}</fileNamePattern>
        <maxHistory>${MAX_LOG_HISTORY}</maxHistory>
    </rollingPolicy>
    <encoder>
        <pattern>${LOGGING_PATTERN}
        </pattern>
    </encoder>
</appender>
<logger name="com.ericsson" level="Error" additivity="false">
    <appender-ref ref="FILE" />
</logger>
<logger name="com.ericsson" level="INFO" additivity="false">
    <appender-ref ref="FILE" />
</logger>
<logger name="com.ericsson" level="DEBUG" additivity="false">
    <appender-ref ref="FILE" />
</logger>

<root level="DEBUG">
    <appender-ref ref="STDOUT" />
</root>

рüффп
  • 5,172
  • 34
  • 67
  • 113
vd86
  • 11
  • 1
  • which version of ServiceMix? – Achim Nierbeck Mar 07 '14 at 19:37
  • service mix version is : 4.5.3. I just checked, Actually it is not able to find logback.xml in its classpath. i tried adding the logback.xml location in org.ops4j.pax.logging.logback.config.file parameter but in vain. – vd86 Mar 09 '14 at 07:07

1 Answers1

2

As Servicemix 4.x is based on top of Karaf, the standard logging mechanism is Pax Logging. Pax Logging is configured by the org.ops4j.pax.logging.cfg file, as Karaf uses Configuration Admin Service to configure OSGi services. That's why the config file still uses the log4j properties notation. If you need special appenders, some are already included like a MDC appender for logging bundle wise, or a ZipRollingFileappender. Support for the external logback configuration was introduced with Pax Loggin 1.7 I think, and I doubt it is already included in ServiceMix 4.5.x So you have to stick to the log4j notation or exchange the Pax Logging versions yourself.

Achim Nierbeck
  • 5,265
  • 2
  • 14
  • 22