• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Odd validation error in log4j.xml

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My 64-bit Eclipse running on Windows with Tomcat 7.0 is getting bent out about of shae. It's claiming that the following is missing well-formed elements after the "log4j:configuration" line. Any tips welcome. Thanks.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="webapp" version="3.0"/>

<log4j:configuration>
<appender name="stdout" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} %5p %c{1}:%L - %m%n"/>
</layout>
</appender>

<ajs.HWServlet>
<priority value="debug"/>
<appender-ref ref="stdout"/>
</ajs.HWServlet>

<root>
<priority value="debug"/>
<appender-ref ref="stdout"/>
</root>
</log4j:configuration>

</web-app>

 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the log4j configuration doing in your web application deployment descriptor ? Shouldn't it be in its own log4j.xml ?
 
Austin Shelton
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My log4j.xml file is both in my WebContent section of my Eclipse workbench and synchronized with an external file. Changes I make in Eclipse are automatically reflected in the external file. I use an static string to point to the log4j.xml file which I change when deployment time rolls around.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It doesn't explain what log4j:configuration is doing in the web-app tag of your web.xml. That's web.xml that you have pasted here, isn't it ?
 
Austin Shelton
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a log4j.xml file and has nothing to do with my web.xml file. I'm sorry if I didn't make that clear before. BTW, not having the "web-app" declaration causes other errors in Eclipse (which I cannot unfortunately remember now). In any event, the "web-app" declaration should do no harm. The problem is with the incomprehensible message that the log4j:configuration tag produces. It looks like all my tags contained therein are correctly well-formed. I guess I need another set of eyes to look at it and offer opinions on the whole in general.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

In any event, the "web-app" declaration should do no harm.


If has nothing to do here. Remove it And fix those errors first.
 
Saloon Keeper
Posts: 28717
211
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whether stuffing in an unrelated element to an XML file "does no harm" depends entirely on how the XML is parsed and processed. Anything could happen, right up to and including crashing the entire application.

You didn't quote the error message, but the implication is that the Log4J xml parser is at that web.xml.

Making an IDE happy is a very bad reason for building invalid config files.
 
Austin Shelton
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good points. I'll try removing the web-app declaration and see what that does.
 
Austin Shelton
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Problem solved. I removed the "web-app" declaration at the beginning of my log4j.xml file and corrected the markup inside of it:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration>
<appender name="stdout" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} %5p %c{1}:%L - %m%n"/>
</layout>
</appender>

<logger name="ajs.HWServlet">
<level value="debug"/>
<appender-ref ref="stdout"/>
</logger>

<root>
<priority value="debug"/>
<appender-ref ref="stdout"/>
</root>
</log4j:configuration>
 
reply
    Bookmark Topic Watch Topic
  • New Topic