I am not sure but I think that you should not try to
write directly to
the file system from j2ee.
I do not think that your configuration file is used by
jboss.
Use jboss log4j.xml configuration it works great.

-----Original Message-----
From: Roger Tucker [mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 29, 2004 8:49 PM
To: '[EMAIL PROTECTED]'
Subject: log4j in jboss


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.DistributionSystemsSearc
h=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  


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to