Help with logback configuration

Thanks for your help...I just switched from log4j to slf4j/logback and this is one issue holding us up from moving to QA/UAT...so I am on a fire drill. If what I have here is not the right way to think about logging for my scenario...please let me know. I have multiple variations I have tried, but I will list the two here. WLS 11g, in my war [SLF4J 1.6.1 api/ext, Logback 0.9.27 core/classic, log4j-over-slf4j 1.6.1, jcl-over-slf4j 1.6.1] I have multiple wars that run in 1+ managed instances of WLS that write to the same central log files. Trying to have one central log and each application have their individual log files (but one across the managed instances...unless it's easier for each managed instance to have its own copy). 1) I included slf4j/logback jars in WLS lib directory and add one logback.xml file into the main/resources directory so when the war is built it gets put into WEB-INF/classes of the war. - No log files are produced at all, not even writing a 0 byte file. 2) I included slf4j/logback in a preclasspath folder that I add into WLS startup scripts and I also added -Dlogback.configurationFile=%DOMAIN_HOME%\lib\logback.xml into the startup script. I excluded a configuration file from the war. - Log files are created, but nothing is printed to any of the log files. Here is my config: <configuration> <appender name="sc-resources.log" class="ch.qos.logback.core.rolling.RollingFileAppender"> <prudent>true</prudent> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <!-- daily rollover --> <fileNamePattern>./logs/sc-resources.%d{yyyy-MM-dd}.log</fileNamePattern> <!-- keep 30 days worth of history --> <maxHistory>30</maxHistory> </rollingPolicy> <encoder> <pattern>%d [%thread] %level %logger - %m%n</pattern> </encoder> </appender> <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>%d [%thread] %level %logger - %m%n</pattern> </encoder> </appender> <logger name="com.foo.service.mem" level="trace"> <appender-ref ref="MemberSearchBusinessService" /> </logger> <appender name="MemberBusinessService" class="ch.qos.logback.core.rolling.RollingFileAppender"> <prudent>true</prudent> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <!-- daily rollover --> <fileNamePattern>./logs/MemberBusinessService%d{yyyy-MM-dd}.log</fileNamePattern> <!-- keep 30 days worth of history --> <maxHistory>30</maxHistory> </rollingPolicy> <encoder> <pattern>%d [%thread] %level %logger - %m%n</pattern> </encoder> </appender> <logger name="com.foo.service.mem" level="trace"> <appender-ref ref="MemberBusinessService" /> </logger> <logger name="org.apache.cxf" level="debug"> <appender-ref ref="sc-resources.log" /> </logger> <logger name="org.hibernate" level="warn"> <appender-ref ref="sc-resources.log" /> </logger> <logger name="org.quartz" level="warn"> <appender-ref ref="sc-resources.log" /> </logger> <logger name="org.springframework" level="warn"> <appender-ref ref="sc-resources.log" /> </logger> <root level="trace"> <appender-ref ref="stdout" /> <appender-ref ref="sc-resources.log"/> </root> </configuration> Thanks for your help....jay -- View this message in context: http://old.nabble.com/Help-with-logback-configuration-tp30846851p30846851.ht... Sent from the Logback User mailing list archive at Nabble.com.

It's not clear if you want to have more than once process write to a single file. That can be done, but is best avoided. If you want to have one file aggregating the activity of mulitple processes, then consider sending the data to a single process which then writes the file. As for why your config is not working, did you try this? -Dlogback.statusListenerClass=ch.qos.logback.core.status.OnConsoleStatusListener jaybytez wrote:
Thanks for your help...I just switched from log4j to slf4j/logback and this is one issue holding us up from moving to QA/UAT...so I am on a fire drill.
If what I have here is not the right way to think about logging for my scenario...please let me know.
I have multiple variations I have tried, but I will list the two here.
WLS 11g, in my war [SLF4J 1.6.1 api/ext, Logback 0.9.27 core/classic, log4j-over-slf4j 1.6.1, jcl-over-slf4j 1.6.1]
I have multiple wars that run in 1+ managed instances of WLS that write to the same central log files. Trying to have one central log and each application have their individual log files (but one across the managed instances...unless it's easier for each managed instance to have its own copy).
1) I included slf4j/logback jars in WLS lib directory and add one logback.xml file into the main/resources directory so when the war is built it gets put into WEB-INF/classes of the war. - No log files are produced at all, not even writing a 0 byte file. 2) I included slf4j/logback in a preclasspath folder that I add into WLS startup scripts and I also added -Dlogback.configurationFile=%DOMAIN_HOME%\lib\logback.xml into the startup script. I excluded a configuration file from the war. - Log files are created, but nothing is printed to any of the log files.
Here is my config: <configuration>
<appender name="sc-resources.log" class="ch.qos.logback.core.rolling.RollingFileAppender"> <prudent>true</prudent> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <!-- daily rollover -->
<fileNamePattern>./logs/sc-resources.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- keep 30 days worth of history --> <maxHistory>30</maxHistory> </rollingPolicy> <encoder> <pattern>%d [%thread] %level %logger - %m%n</pattern> </encoder> </appender>
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>%d [%thread] %level %logger - %m%n</pattern> </encoder> </appender>
<logger name="com.foo.service.mem" level="trace"> <appender-ref ref="MemberSearchBusinessService" /> </logger>
<appender name="MemberBusinessService" class="ch.qos.logback.core.rolling.RollingFileAppender"> <prudent>true</prudent> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <!-- daily rollover -->
<fileNamePattern>./logs/MemberBusinessService%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- keep 30 days worth of history --> <maxHistory>30</maxHistory> </rollingPolicy> <encoder> <pattern>%d [%thread] %level %logger - %m%n</pattern> </encoder> </appender>
<logger name="com.foo.service.mem" level="trace"> <appender-ref ref="MemberBusinessService" /> </logger>
<logger name="org.apache.cxf" level="debug"> <appender-ref ref="sc-resources.log" /> </logger>
<logger name="org.hibernate" level="warn"> <appender-ref ref="sc-resources.log" /> </logger>
<logger name="org.quartz" level="warn"> <appender-ref ref="sc-resources.log" /> </logger>
<logger name="org.springframework" level="warn"> <appender-ref ref="sc-resources.log" /> </logger>
<root level="trace"> <appender-ref ref="stdout" /> <appender-ref ref="sc-resources.log"/> </root> </configuration>
Thanks for your help....jay
-- View this message in context: http://old.nabble.com/Help-with-logback-configuration-tp30846851p30856858.ht... Sent from the Logback User mailing list archive at Nabble.com.

So I backed out everything and am trying to go to something very basic. Everything logs to the console, but nothing to the single log file. 1) I have the two logback jars and slf jars in WebLogic's lib directory. 2) I have the following added to the startManagedWebLogic.cmd so the config file is externalized [-Dlogback.statusListenerClass=ch.qos.logback.core.status.OnConsoleStatusListener -Dlogback.configurationFile=C:\NotBackedUp\tools\wls_10.3.4.0\user_projects\domains\fsscDomain\lib\logback.xml]. 3) I have the following configuration below: <configuration> <appender name="sc-resources.log" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>C:/NotBackedUp/tools/wls_10.3.4.0/user_projects/domains/fsscDomain/logs/sc-resources.log</file> <append>true</append> <prudent>true</prudent> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <!-- daily rollover --> <fileNamePattern>C:/NotBackedUp/tools/wls_10.3.4.0/user_projects/domains/fsscDomain/logs/sc-resources.%d{yyyy-MM-dd}.log</fileNamePattern> <!-- keep 30 days worth of history --> <maxHistory>10</maxHistory> </rollingPolicy> <encoder> <pattern>%d [%thread] %level %logger - %m%n</pattern> </encoder> </appender> <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>%d [%thread] %level %logger - %m%n</pattern> </encoder> </appender> <root level="trace"> <appender-ref ref="stdout" /> <appender-ref ref="sc-resources.log"/> </root> </configuration> The log files are created, logger statements write to the console, but nothing ever gets written to the log files. Please let me know what I can do to get this working... Is it not recommended to have an externalized config file? Because I might have scenarios where I have an Admin Server and n+1 Managed Servers that exist in the JVM and multiple wars can be deployed on those Managed Servers so I assume they will be writing to the same log file...which seems to be a problem. But even if I put in prudent to test...it doesn't work. Here is the WebLogic Console (again...nothing gets written to the log file, but I do see items going to the console): Thanks for your help, Jay -- View this message in context: http://old.nabble.com/Help-with-logback-configuration-tp30846851p30885813.ht... Sent from the Logback User mailing list archive at Nabble.com.
participants (2)
-
David Roussel
-
jaybytez