William,
Two things you can try:
First, add an explicit path to the log file name. So set it to
/var/log/axis/axis.log or /home/you/logs/axis.log or c:/tmp/logs/axis.log
or whatever is appropriate depending on platform, perms, etc. You can
also
do something like ${catalina.home}/logs/axis.log or something like that
too. What's valid is very dependent on your environment, so play around
with that. The default directory for log output is the current directory,
which in the case of a servlet container will usually be the container's
home directory. So, for example, for Tomcat this means your
/usr/local/tomcat or c:\Tomcat or wherever you've got it installed. I'm
not sure where these might go for other containers.
Second, check which log4j.properties file you're loading. I have a little
code snippet here:
http://slapfest.blogspot.com/2005/07/what-version-of-class-or-resource-am-i.html
that you can use to find your log4j.properties. There may be a problem
with that: in the cl.getResource() call, you may need to use
"log4j.properties" rather than "/log4j.properties", but I can't remember.
That'll tell you if your definition is even getting loaded or if your
servlet container is actually getting another log4j config from somewhere
else.
As far as your progammatically created appender, I can tell you why you
won't see any output from there: you're not adding the appender to your
logger. Try something like this:
Logger logger = Logger.getLogger(EchoService.class);
BasicConfigurator.configure();
SimpleLayout layout = new SimpleLayout();
FileAppender appender = new FileAppender(layout,"connectionlog.txt",true);
if (appender != null)
{
logger.addAppender(appender);
}
BTW, as far as the BasicConfigurator stuff? My guess is that that call is
completely unnecessary and could even screw up your configuration (which
is
another possible reason why you might not be seeing any output into your
log files, if it's somehow nuking the default configuration, which
actually
uses PropertyConfigurator).
"William Mok"
<[EMAIL PROTECTED]
m> To
"Log4J Users List"
08/16/2005 11:57 <log4j-user@logging.apache.org>
AM cc
Subject
Please respond to Re: Log4j Configuration
"Log4J Users
List"
<[EMAIL PROTECTED]
ng.apache.org>
Thanks,
I have included the log4j.properties file in the CLASSPATH and restart
tomcat, but I could not find any log file generated under the entire
tomcat
directory, after running the servlet.
----- Original Message -----
From: "Harp, George" <[EMAIL PROTECTED]>
To: "'Log4J Users List'" <log4j-user@logging.apache.org>
Sent: Tuesday, August 16, 2005 10:51 AM
Subject: RE: Log4j Configuration
I don't have to put any configuration code in my appliaction I just make
sure that log4j.properties or log4j.xml is in the clas path.
-----Original Message-----
From: William Mok [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 16, 2005 12:35 PM
To: log4j-user@logging.apache.org
Subject: Log4j Configuration
Hi,
I have the following log4j.properties file:
----------------------------------------------------------------------------
-----------------------------------
# Set root category priority to INFO and its only appender to CONSOLE.
log4j.rootCategory=INFO, CONSOLE
#log4j.rootCategory=INFO, CONSOLE, LOGFILE
# Set the enterprise logger category to FATAL and its only appender to
CONSOLE.
log4j.logger.org.apache.axis.enterprise=FATAL, CONSOLE
# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Threshold=INFO
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=- %m%n
# LOGFILE is set to be a File appender using a PatternLayout.
log4j.appender.LOGFILE=org.apache.log4j.FileAppender
log4j.appender.LOGFILE.File=axis.log
log4j.appender.LOGFILE.Append=true
log4j.appender.LOGFILE.Threshold=INFO
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.LOGFILE.layout.ConversionPattern=%-4r [%t] %-5p %c %x -
%m%n
----------------------------------------------------------------------------
--------------------------------------------------------
At the same time, I also have the following lines in my java servlet
----------------------------------------------------------------------------
--------------------------------------------------------
Logger logger = Logger.getLogger(EchoService.class);
BasicConfigurator.configure();
SimpleLayout layout = new SimpleLayout();
FileAppender appender = null;
try
{
appender = new
FileAppender(layout,"connectionlog.txt",true);
}
----------------------------------------------------------------------------
------------------------------------------------------------
Questions:
1. So how does this configuration work, does the java code override the
configuration on properties file?
2. What does BasicConfigurator do?
3. In propertes file, log4j.appender.LOGFILE.File=axis.log, but I cannot
find this axis.log anywhere after running the servlet.
In the java servlet, I have the line "appender = new
FileAppender(layout,"connectionlog.txt",true);", but I cannot find the
connectionlog.txt file anywhere.
Thanks.
William
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]