I am running a POC to see the impact of migrating our j2ee applications to logback. I spent some time on the official website and apparently, the only change beside new jars was the logback.xml file. Unfortunatly doesn't look to be enough, the deployment works and the log file is created as well, but nothing is logged (empty).
my code has the following statements
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger log = LoggerFactory.getLogger(CustomerServiceBean.class);
log.debug("test Log Back - customer ID " + input.getCustomerId());
pom.xml has now the following
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>0.9.18</version>
</dependency>
logback.xml (created using web utility from the official website)
<configuration>
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!--See also http://logback.qos.ch/manual/appenders.html#RollingFileAppender-->
<File>/var/log/dcs-3/dcs3.log</File>
<encoder>
<pattern>%d{ABSOLUTE} %5p %c{1}:%L - %m%n</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<maxIndex>1</maxIndex>
<FileNamePattern>/var/log/dcs-3/dcs3.log.%i</FileNamePattern>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>1MB</MaxFileSize>
</triggeringPolicy>
</appender>
<logger name="com.lgi.dcs" level="DEBUG" />
<root level="debug">
<appender-ref ref="file"/>
</root>
</configuration>
any idea? thanks
UPDATE
I made few more changes as suggested. The issue is still open, however I was able to obtain more information.
I logged an ERROR instead of a simple DEBUG. I removed all log4j jars or dependencies from the project and added the log4j-bridge. I changed the logback.xml with one more generic taken from another post and used an appender on the console in addition to the file.
Now in my IDE looks like the Logger instance is implemented by ch.qos.locback.classic.Logger. The log file is still empty, but if I delete it than is recreated during server start-up. On the server log I can now see the my test message like:
SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [zip:/opt/oracle-soa/user_projects/domains/osb/servers/AdminServer/tmp/_WL_user/dcs3-ear-3/9yhkv9/APP-INF/lib/logback-classic-0.9.18.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [zip:/opt/oracle-soa/user_projects/domains/osb/servers/AdminServer/tmp/_WL_user/dcs3-ear-3/9yhkv9/APP-INF/lib/logback-classic-0.9.18.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. 11:40:17.902 [[ACTIVE] ExecuteThread: '12' for queue: 'weblogic.kernel.Default (self-tuning)'] ERROR c.l.d.s.customer.CustomerServiceBean - test Log Back - customer ID 6107576
which some how makes me think about the log4j within weblogic perhaps.