[logback-user] How to ensure initialization (StaticLoggerBinder.init())?

Daniel Guggi daniel.guggi at gmail.com
Mon Oct 3 10:34:56 CEST 2011


hi guys,

I try to configure logback for our application in glassfish (3.1) as
follows:

[*] I start gf with -Dlogback.configurationFile=/path/to/file

[*] logback.xml is:
*<configuration>
<!--
  <insertFromJNDI env-entry-name="java:app/AppName" as="appName" />
  <contextName>${appName}</contextName>
-->
  <appender name="FILE" class="ch.qos.logback.core.FileAppender">
    <file>../logs/r6.log</file>
    <encoder>
      <pattern>%date %-5p [%thread] [%contextName] [%logger{20}]
%msg%n</pattern>
    </encoder>
  </appender>
  <root level="debug">
    <appender-ref ref="FILE" />
  </root>
</configuration>
*
So far everything works fine. However I encountered a problem in the
following situation.

[*] A simple message driven bean, which is invoked if there are new messages
in a given "jms-queue" like this:*
@MessageDriven( mappedName="myQueue", activationConfig =  {
    @ActivationConfigProperty(propertyName = "acknowledgeMode",
                              propertyValue = "Auto-acknowledge"),
    @ActivationConfigProperty(propertyName = "destinationType",
                              propertyValue = "javax.jms.Queue")
})
public class MyMdb implements MessageListener {

    private static Logger logger = LoggerFactory.getLogger(MyMdb.class);

    @Override
    public void onMessage(Message msg) {
        logger.info("got message...");
    }
}*

[*] Glassfish is not running, AND there ARE messages in the queue
[*] Now when I start glassfish the application (MyMdb) start receiving the
messages from the queue
[*] At this point logback is not yet initialized, as I see the following
messages in my logfile:

*The following loggers will not work becasue they were created during the
default configuration phase of the underlying logging system.  See also
http://www.slf4j.org/codes.html#substituteLogger*

Any ideas how to solve this?

tia,
daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://qos.ch/pipermail/logback-user/attachments/20111003/06146299/attachment.html>


More information about the Logback-user mailing list