Theis is my log4j.properties file:
log4j.rootCategory=INFO, R
log4j.logger.com.smsoffice=DEBUG
#log4j.logger.org.apache.wicket=DEBUG
#log4j.logger.org.hibernate=DEBUG
#log4j.additivity.org.hibernate.SQL=false
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=${catalina.home}/webapps/ROOT/logs/smsoffice.log
log4j.appender.R.MaxFileSize=10MB
log4j.appender.R.MaxBackupIndex=20
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d{dd-MM-yyyy HH:mm:ss,SSS} %p %C.%M:%L - %m%n
This file is in src/main/resources. I am using tomcat web server. In com.smsoffice.launch I have WebApp.java and I am using log4j in this way:
private static final Logger logger = Logger.getLogger(WebApp.class);
logger.info("Initializing web application");
When I start the app log4j writes in the console only this:
log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext). log4j:WARN Please initialize the log4j system properly.
I have logs in ${catalina.home}/webapps/ROOT/logs/smsoffice.log but it is not shown in the console when I am debuging.
Anyone knows what I am missing ?
EDIT:
here is the full log:
log4j: Trying to find [C:\projects\smsofficenew\app\sms-office-webapp\src\main\resources\log4j.properties] using context classloader WebappClassLoader
context: /ROOT
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@1489c411
.
log4j: Trying to find [C:\projects\smsofficenew\app\sms-office-webapp\src\main\resources\log4j.properties] using WebappClassLoader
context: /ROOT
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@1489c411
class loader.
log4j: Trying to find [C:\projects\smsofficenew\app\sms-office-webapp\src\main\resources\log4j.properties] using ClassLoader.getSystemResource().
log4j: Could not find resource: [C:\projects\smsofficenew\app\sms-office-webapp\src\main\resources\log4j.properties].
log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
BUT the resource [C:\projects\smsofficenew\app\sms-office-webapp\src\main\resources\log4j.properties] is here !!! So the real problem is why log4j cannot find this file ???