How to "Added -Dlog4j.debug to the command line"? Would you give me an
example?

On 3/14/06, James Stauffer <[EMAIL PROTECTED]> wrote:
>
> Verify that it is configured before you attempt to use a Logger.
> Added -Dlog4j.debug to the command line to give you more info.
>
> On 3/14/06, red phoenix <[EMAIL PROTECTED]> wrote:
> > I have some file like follows:
> > C:\tomcat5\webapps\ROOT\WEB-INF\web.xml
> > C:\tomcat5\webapps\ROOT\WEB-INF\conf\log4j.properties
> > C:\tomcat5\webapps\ROOT\WEB-INF\classes\test\LogServlet.class
> > C:\tomcat5\webapps\ROOT\WEB-INF\classes\abc\test.class
> >
> > and I use servlet to initial log4j,like follows:
> >
> > /*LogServlet.java*/
> > package test;
> > import javax.servlet.*;
> > import javax.servlet.http.*;
> > import org.apache.log4j.PropertyConfigurator;
> > public class LogServlet extends HttpServlet{
> >   public void init() throws ServletException {
> >         String prefix = getServletContext().getRealPath("/");
> >         String file =
> > getServletConfig().getInitParameter("log4j-config-file");
> >         if(file != null)
> >             PropertyConfigurator.configure(prefix + file);
> >    }
> >    public void doPost(HttpServletRequest request, HttpServletResponse
> > response)  throws ServletException, IOException{}
> > }
> >
> > /*web.xml*/
> > .......
> > <servlet>
> >    <display-name>LogServlet</display-name>
> >   <servlet-name>LogServlet</servlet-name>
> >   <servlet-class>
> >    test.LogServlet
> >   </servlet-class>
> >   <init-param>
> >    <param-name>log4j-config-file</param-name>
> >    <param-value>
> >     /WEB-INF/conf/log4j.properties
> >    </param-value>
> >   </init-param>
> >   <load-on-startup>1</load-on-startup>
> >  </servlet>
> >
> > /*log4j.properties*/
> > log4j.logger.A1=INFO, A1
> > log4j.appender.A1=org.apache.log4j.ConsoleAppender
> > log4j.appender.A1.layout=org.apache.log4j.PatternLayout
> > log4j.appender.A1.layout.ConversionPattern=%m%n
> >
> > I find LogServlet execute successful,and then I write a class to write
> > log,like follows:
> >
> > package abc;
> > import org.apache.log4j.Logger;
> > public class test{
> >  private static Logger log;
> >  public static void main(String args[]){
> >    Logger log=Logger.getLogger("A1");
> >   log.error("test");
> >  }
> >
> > When I run test.class,I got error:
> >
> > log4j:WARN No appenders could be found for logger (A1).
> > log4j:WARN Please initialize the log4j system properly.
> >
> > Why raise above error? I am puzzled with it.
> > Thanks in advance.
> >
> >
>
>
> --
> James Stauffer
> Are you good? Take the test at http://www.livingwaters.com/good/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to