I have been trying to get my application to log using the log4j jar. It works fine in Dev Mode, but when I deploy it to tomcat the log files denoted by the configuration don't even seem to appear.
The following log4j.properties file is in my war directory for my app:
Just to get it working I have a simple class with static log methods only accessing the rootLogger:
On server side calls I simply have statements such as:
Are there settings within the Tomcat environment to allow application specific use of log4j, or am I simply going about this wrong?
The following log4j.properties file is in my war directory for my app:
Code:
log4j.rootLogger=ALL, main, error log4j.appender.main=org.apache.log4j.RollingFileAppender log4j.appender.main.maxFileSize=100KB log4j.appender.main.maxBackupIndex=5 log4j.appender.main.File=ramsi.log log4j.appender.main.threshold=debug log4j.appender.main.layout=org.apache.log4j.PatternLayout log4j.appender.main.layout.ConversionPattern=%d{HH:mm:ss MM-dd-yyyy} %5p - %m%n log4j.appender.error=org.apache.log4j.RollingFileAppender log4j.appender.error.maxFileSize=100KB log4j.appender.error.maxBackupIndex=5 log4j.appender.error.File=error.log log4j.appender.error.threshold=error log4j.appender.error.layout=org.apache.log4j.PatternLayout log4j.appender.error.layout.ConversionPattern=%d{HH:mm:ss MM-dd-yyyy} %5p - %m%n
Code:
public class MyLogger { private static Logger LOGGER = Logger.getRootLogger(); static public void doInfo(String className, String message) { LOGGER.info(className + " - " + message); } }
Code:
MyLogger.doInfo(UserServiceImpl.class.getName(), "Getting User information for " + temp.getName());
Comment