Hi,
I'm attempting to set up logging using log4j in a jboss servlet. The code
from my servlet looks like this:
****************************************************************************
**********************************************
private void initLogging() throws IOException {
PrintWriter out = response.getWriter();
InputStream is =
session.getServletContext().getResourceAsStream("log4j.properties");
Properties prop = new Properties();
prop.load(is);
PropertyConfigurator.configure(prop);
Logger logger =
Logger.getLogger("com.tclick.agencyManagement.search.SearchParams");
logger.debug("Test");
****************************************************************************
***************************************************
My properties file looks like this:
****************************************************************************
****************************************
# Set root logger level to DEBUG and its only appender to AMS.
log4j.logger.com.tclick.agencyManagement.search.SearchParams=DEBUG, AMS
log4j.logger.com.tclick.agencyManagement.search.DistributionSystemsSearch=DE
BUG, AMS
# AMS is set to be a RollingFileAppender
log4j.appender.AMS=org.apache.log4j.RollingFileAppender
log4j.appender.AMS.File="c:\\agencyManagement.log"
log4j.appender.AMS.MaxFileSize=100MB
log4j.appender.AMS.DatePattern='.'yyyy-MM-dd
log4j.appender.AMS.MaxBackupIndex=1
# AMS uses PatternLayout.
log4j.appender.AMS.layout=org.apache.log4j.PatternLayout
log4j.appender.AMS.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
****************************************************************************
******
The servlet has no problem actually finding the property file. Once I
have the property file loaded I have no problems grabbing values from the
property file and
displaying them using the servlet's PrintWriter.
The problem is that the log file never gets created and nothing ever gets
written to it. Notice the logger.debug("Test") at the end of the servlet
code. That never gets written the specified log file.
As an added piece of information, jboss uses log4j for it's internal
logging. Does this have an impact on the way I set up my logging?
I am fairly new to log4j. My goal is to be able to configure log4j here
in the servlet and allow the rest of the webapp code to be able to grab
instance of these loggers using the Logger.getLogger(<class>) call.
Thanks in advance
Roger Tucker