I'm having some trouble configuring tomcat 8 logging for my wicket 7
application.

Based on mykong's example here I set up my application's pom and adde the
log4.j properties file:

http://www.mkyong.com/wicket/wicket-log4j-integration-example/

My log4j.properties file:

log4j.rootLogger=INFO, stdout, file

# Redirect log messages to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p
%c{1}:%L - %m%n

log4j.logger.com.ds=INFO
log4j.logger.org.springframework=WARN
log4j.logger.org.hibernate=WARN
log4j.logger.org.eclipse.jetty=INFO

# Redirect log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=${catalina.home}/logs/aleron.log
log4j.appender.file.MaxFileSize=5KB
log4j.appender.file.MaxBackupIndex=5
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p
%c{1}:%L - %m%n
Based on this documentation I've made sure the the jar is present in the lib
directory:

https://tomcat.apache.org/tomcat-8.0-doc/logging.html

I've added the following to CATALINA_OPTS based on this SO page:

Log4J properties file - where to put it

I've chekc the logs and it appears that the property file is being loaded:

og4j: Trying to find [log4j.xml] using context classloader WebappClassLoader
  context: deathstar
  delegate: false
----------> Parent Classloader:
java.net.URLClassLoader@3b07d329
.
log4j: Trying to find [log4j.xml] using WebappClassLoader
  context: deathstar
  delegate: false
----------> Parent Classloader:
java.net.URLClassLoader@3b07d329
 class loader.
log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
log4j: Trying to find [log4j.properties] using context classloader
WebappClassLoader
  context: deathstar
  delegate: false
----------> Parent Classloader:
java.net.URLClassLoader@3b07d329
.
log4j: Using URL
[file:/opt/apache-tomcat-8.0.24/webapps/deathstar/WEB-INF/classes/log4j.properties]
for automatic log4j configuration.
log4j: Reading configuration from URL
file:/opt/apache-tomcat-8.0.24/webapps/deathstar/WEB-INF/classes/log4j.properties
log4j: Parsing for [root] with value=[INFO, stdout, file].
log4j: Level token is [INFO].
log4j: Category root set to INFO
log4j: Parsing appender named "stdout".
log4j: Parsing layout options for "stdout".
log4j: Setting property [conversionPattern] to [%d{yyyy-MM-dd HH:mm:ss} %-5p
%c{1}:%L - %m%n].
log4j: End of parsing for "stdout".
log4j: Setting property [target] to [System.out].
log4j: Parsed "stdout" options.
log4j: Parsing appender named "file".
log4j: Parsing layout options for "file".
log4j: Setting property [conversionPattern] to [%d{yyyy-MM-dd HH:mm:ss} %-5p
%c{1}:%L - %m%n].
log4j: End of parsing for "file".
log4j: Setting property [file] to
[/opt/apache-tomcat-8.0.24/logs/aleron.log].
log4j: Setting property [maxBackupIndex] to [5].
log4j: Setting property [maxFileSize] to [5KB].
log4j: setFile called: /opt/apache-tomcat-8.0.24/logs/aleron.log, true
log4j: setFile ended
log4j: Parsed "file" options.
log4j: Parsing for [com.ds] with value=[INFO].
log4j: Level token is [INFO].
log4j: Category com.ds set to INFO
log4j: Handling log4j.additivity.com.ds=[null]
log4j: Parsing for [org.springframework] with value=[WARN].
log4j: Level token is [WARN].
log4j: Category org.springframework set to WARN
log4j: Handling log4j.additivity.org.springframework=[null]
log4j: Parsing for [org.eclipse.jetty] with value=[INFO].
log4j: Level token is [INFO].
log4j: Category org.eclipse.jetty set to INFO
log4j: Handling log4j.additivity.org.eclipse.jetty=[null]
log4j: Parsing for [org.hibernate] with value=[WARN].
log4j: Level token is [WARN].
log4j: Category org.hibernate set to WARN
log4j: Handling log4j.additivity.org.hibernate=[null]
log4j: Finished configuring.
I had to add the following exclusion to my webapps pom to get it to works
based on the suggestion I saw in the console:

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-web</artifactId>
   <version>1.1.8.RELEASE</version>
   <exclusions>
      <exclusion>
         <groupId>org.slf4j</groupId>
         <artifactId>log4j-over-slf4j</artifactId>
      </exclusion>
   </exclusions>
</dependency>
Everything seems fine, but the output ignores this configuration.

My aleron.log file is created but stays empty.
catalina.out is not affected by any of these configurations and is flooded
with debug info.
Note, this is only an issue when I ran this configuration on Tomcat, locally
the log4j properties file is loaded and work fine in IntelliJ.

Used versions:

Tomcat: 8.0.24 Wicket: 7.0.0-M5 Java: 1.7 slf4j-log4j12: 1.6.1

My goals is to get to using the logs level cnfigured whiel deployed to
Tomcat 8 and using aleron.log as an output. I'm probably missing something
simple.

Any suggestions? Thanks in advance.

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Tomcat-8-log4j-wicket-7-configuration-tp4672210.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to