Eclipse: Referencing log4j.dtd in log4j.xml

后端 未结 6 1794
既然无缘
既然无缘 2020-11-30 20:21

I\'ve been using log4j for quite a while now and I usually use this at the top of the log4j.xml (probably just like many others and according to Google this is the

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-30 20:42

    Try to add the log4j.dtd as a User Specific URI XML Catalog Entry in "Preferences -> XML -> XML Catalog". As I know this is the place where eclipse manages the references to definition/validation files (like xsd). If they can be found here eclipse needs no internet access to access them on their native (web) location.

    I did it like this (for test) and eclipse does not complain:

    Entry element:    URI
    Location:         C:\Users\me\Desktop\log4j.dtd
    URI:              file:///C:/Users/me/Desktop/log4j.dtd
    Key type:         URI
    Key:              http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd
    

    Maybe also ${M2_REPO} works - I did not check this.

    Use the native URL in your log4j.xml afterwards

    
    

    EDIT

    I would go with the above solution but to come back to your question, I think class path variables 'can be used in a Java Build Path'. Why should they work inside a DOCTYPE definition? "Validate" (eclipse context menu) the log4j.xml file and you will get a warning that the path can not be resolved.

    I hoped classpath:org/apache/log4j/xml/log4j.dtd would do the trick but that protocol is also not support (see validation error). I am afraid it will not work out of the box.

    And, as I understood, the SYSTEM "log4j.dtd" notation is no placeholder. It is a valid reference to a document that is expected to be found next to the dtd (in this case).

提交回复
热议问题