[logback-user] Logback configuration in Virgo OSGi container

mvwinsen mvwinsen at gmail.com
Tue May 31 21:22:16 CEST 2011


Hi,

i'm trying to get logback logging working in my Virgo OSGi container.
Doing this i'm having some difficulties logging to the rootLogger.

Virgo is delivered with a serviceability.xml (which is a renamed logback.xml
file).
I want to have 'one' logconfiguration (preferabably the serviceability.xml)
used by all bundles inside the container. Therefore i've set the VM arg
-Dlogback.configurationFile=./config/serviceability.xml. So that the default
log configuration is read from that file. When i start the container i see
that the logging configuration is setted by default to the
./config/serviceablity.xml (i can see this because i've set the debug to
true in the configuration tag of the xml file).
In that configuration i've set the root level to info (see file below):

<configuration debug="true" scan="true">
 <jmxConfigurator/>
 <appender name="GENERAL"
class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>./serviceability/logs/GeneralTest.log</file>
    <rollingPolicy
class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
     
<fileNamePattern>./serviceability/logs/General.%i.log</fileNamePattern>
      <minIndex>1</minIndex>
      <maxIndex>5</maxIndex>
    </rollingPolicy>

    <triggeringPolicy
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
      <maxFileSize>5MB</maxFileSize>
    </triggeringPolicy>
    <encoder>
      <pattern>%-5p %d{ISO8601} [%18.18t] %50.50c : %m%n</pattern>
    </encoder>
  </appender>

	<root level="INFO">
		<appender-ref ref="GENERAL" />		
	</root>
</configuration>

The problem that i'm facing it that when i ask log4j-over-slf4j  to get a
logger via the code, then the bundle is falling back to the default
configuration of logback (not the one set via the VM args, and therefore is
logging console of my Eclipse environment. And nothing to the log file.

org.apache.log4j.Logger log;
log = Logger.getLogger("logger1");
log.error("test123");

The strange thing is that when i add the above descibed logback.xml
configuration to the bundle where i'm trying to log
(src/main/resources/logback.xml), then the root logger is linked to the
logfile and de log line is outputted to the file.

Does anyone has an idea what i'm doing wrong?
My goal is to set the logconfigation once as VM arg and just call the
Logger.GetLogger('id') of any bundle in the container and log the line to
the root logger which is descibed in the logconfiguration.

Thanks in advance,

Mark

-- 
View this message in context: http://old.nabble.com/Logback-configuration-in-Virgo-OSGi-container-tp31743236p31743236.html
Sent from the Logback User mailing list archive at Nabble.com.



More information about the Logback-user mailing list