0

Trying to get logback working in my application -- I have a resource adapter and an MDB deployed under Weblogic. I've swapped the application from using log4j to logback/slf4j.

Configuration files are placed under /src/main/resources (though I have also placed them under the root of the java class folder - no luck)

There is no indication of the logback.xml file being found. Even if it's not found though, I would have expected the logs to appear in the console. I'm not seeing anything.

My logback.xml is as follows:

<configuration debug="true">

  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
      <pattern>%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n</pattern>
    </encoder>
  </appender>

  <appender name="KafkaRALogFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>/data/apps/applications/jmsDomain/kafkaresourceadapter/logs/resourceadapter.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
      <fileNamePattern>/data/apps/applications/jmsDomain/kafkaresourceadapter/logs/resourceadapter-%d{yyy-MM-dd}.%i.log</fileNamePattern>
      <maxHistory>5</maxHistory>
      <totalSizeCap>20MB</totalSizeCap>
    </rollingPolicy>
    <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
        <maxFileSize>5MB</maxFileSize>
    </triggeringPolicy>
    <encoder>
      <pattern>%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n</pattern>
    </encoder>
  </appender>
  
  <logger name="ca.bellaliant.kafkaresourceadapter" level="DEBUG" additivity="false">
      <appender-ref ref="STDOUT" />
      <appender-ref ref="KafkaRALogFile" />
  </logger>
  
  <!-- By default, the level of the root level is set to DEBUG -->
  <root level="DEBUG">
      <appender-ref ref="STDOUT" />
  </root>

</configuration>

Here are the relevant snippets of code. Note that the System.out is getting executed and I am seeing that line of text in my sysout:

importing the correct class files:
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SomeAdapter implements ResourceAdapter
{
   private static final Logger logger = LoggerFactory.getLogger(SomeAdapter.class);
   private WorkManager workManager;
   private final Map<EndpointKey, KafkaWorker> registeredWorkers;

   public KafkaResourceAdapter() {
       registeredWorkers = new ConcurrentHashMap<>();
   }

   public void start( BootstrapContext bsCtx )
   {
      logger.debug("Some statement to log.");
      System.out.println("***Something to go to the stdout.");
          workManager = bsCtx.getWorkManager();
          running = true;
   }

....

I have the following in dependencies added to my pom. From what I understand, I only really need the logback-classic dependency:

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.5.10</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.5.10</version>
        </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.3.5</version>
    </dependency>

Thoughts as to what might be causing grief here?

So far, I've double checked to ensure that the logback and slf4j classes were being loaded in my classloader. I've checked to ensure log4j was not. prefer-application-packages has been added to weblogic-xml to point to slf4j.

Again -- my understanding is that at worst I should at least be seeing output go to the console if the configuration file is found. Previous Log4j implementation was working fine (standalone, no slf4j -- not sure if that might be something to try).

0 Answers0