[logback-user] Logback configuration in Virgo OSGi container

Ceki Gülcü ceki at qos.ch
Tue May 31 21:30:13 CEST 2011

On 31/05/2011 9:22 PM, mvwinsen wrote:
> 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

Hello Mark,

First let me mention that I don't know much about logging in Virgo 
except that its uses logback. From what you describe, it sounds like 
Virgo is detecting the presence of log4j, or log4j-over-slf4j in this 
case, and behaving differently by reverting to the default configuration 

You would probably be better served by contacting the virgo user's 
mailing list. However, if you find the answer to your problem please 
keep us informed.

Best regards,

QOS.ch, main sponsor of cal10n, logback and slf4j open source projects, 
is looking to hire talented software developers. For further details, 
see http://logback.qos.ch/job.html

More information about the Logback-user mailing list