I am wondering why I have this error when deploying my web application.
log4j: Error Could not find value for key log4j.appender.SQL_APPENDER
Here is my log4j.properties
file.
log4j.rootLogger=error, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# Print the date in ISO 8601 format
log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=application.log
log4j.appender.R.MaxFileSize=100KB
# Keep one backup file
log4j.appender.R.MaxBackupIndex=1
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
log4j.logger.org.hibernate.SQL=DEBUG, SQL_APPENDER
log4j.additivity.org.hibernate.SQL=false
Do I have to do some configuration in the server side? I am running my application on a Tomcat 7 server. I added this dependency to the pom.xml
file:
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
Log4j provides Appender objects which are primarily responsible for printing logging messages to different destinations such as console, files, NT event logs, Swing components, JMS, remote UNIX syslog daemons, sockets, etc.
Log4j has three main components: loggers, appenders, and layouts. These components work together to accomplish the following tasks: Record messages based on message type and level.
Log4j2 ConsoleAppender appends the log events generated by application into the System. out or System. err . The default target is System.
You need to define log.appender.SQL_APPENDER
, since you assign it in the line
log4j.logger.org.hibernate.SQL=DEBUG, SQL_APPENDER
You are defining appender R
but no SQL_APPENDER
As SJuan mentioned you need to define
log.appender.SQL_APPENDER
and that is done something like this :
log4j.appender.SQL_APPENDER=org.apache.log4j.RollingFileAppender
and might as well add these while you are at it...
log4j.appender.SQL_APPENDER.File=c:/EC_sql.log log4j.appender.SQL_APPENDER.MaxFileSize=1000KB log4j.appender.SQL_APPENDER.MaxBackupIndex=62 log4j.appender.SQL_APPENDER.layout=org.apache.log4j.PatternLayout log4j.appender.SQL_APPENDER.layout.ConversionPattern=[%d] %5p [%t] (%F:%L) - %m%n
Hope this helps someone!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With