Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

log4j - configuration file

843841Mar 10 2005 — edited Mar 11 2005
where can I find a guide on log4j?
I need to configure the logger, in a configuration file.

I've done it by a init servlet and a configuration file,but tomcat write this message

log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester).
log4j:WARN Please initialize the log4j system properly.

the servlet is this:

package fromBegin.controller;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.PropertyConfigurator;

public class StartUpServlet extends HttpServlet
{
public void init() {
String prefix = getServletContext().getRealPath("/");
String file = getInitParameter("log4j-init-file");

// if the log4j-init-file is not set, then no point in trying
if(file != null) {
PropertyConfigurator.configure(prefix+file);
}
}

public
void doGet(HttpServletRequest req, HttpServletResponse res) {
}
}

the web.xml fragment is this

<servlet>
<servlet-name>startUp</servlet-name>
<servlet-class>fromBegin.controller.StartUpServlet</servlet-class>

<init-param>
<param-name>log4j-init-file</param-name>
<param-value>WEB-INF/log4j.lcf</param-value>
</init-param>

<load-on-startup>1</load-on-startup>
</servlet>



and the configuration file is this:

# file di configurazione per la registrazione dei log
# mediante log4j
.
log4j.rootLogger=DEBUG, R

log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=C:\\Documents and Settings\\Romeo\\Desktop\\Raccolta log\\log4j-track.log

log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n


finally,
anybody knows a online guide for log4j?

why tomcat give me that warning message?

thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 8 2005
Added on Mar 10 2005
3 comments
340 views