Adding the site https://download.eclipse.org/passage/updates/release/2.2.1/ to Window → Preferences → Install/Update → Available Sites and using Help → Check for Updates can be used to upgrade the version of Passage and thereby replace the vulnerable version of log4j2.
Use this simple log4j2. xml for quick reference to log statements in multiple log files. This configuration logs different levels of logs ( debug , info etc.) to different files, using LevelRangeFilter , so that our logs are clean and separated for easy debugging and reporting purposes.
I know this question has been answered, but I'd like to provide my slightly different alternative:
<!DOCTYPE log4j:configuration PUBLIC
"-//APACHE//DTD LOG4J 1.2//EN" "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">
It is similar to @FrVaBe's response, but on the plus side, does not require any further Eclipse configuration (i.e., if you're sharing your project with others, or have a large team, it's one less thing to worry about).
The down side though, is that I believe it means you'll need an Internet connection (at least at some point during development, even if it's just one time).
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
<!DOCTYPE log4j:configuration SYSTEM "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">
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).
I added DTD folder in webcontent and then I copied the log4j dtd file in that. then i tried like bellow. Its working
<!DOCTYPE log4j:configuration SYSTEM "<Path>/DTD/log4j.dtd">
Path means here the project path like /projectname
I have tried with FrVaBe's answer but didn't work for me and I did an small change in the Key value and it works.
"Preferences -> XML -> XML Catalog"
Localization: C:\Users\me\Desktop\log4j.dtd
Key Type: URI
Key: -//APACHE//DTD LOG4J 1.2//EN
@Jack Leow uses a good approach with the PUBLIC ID. Yet, as he points out, it requires a network connection.
I prefer a combination:
Entry element: Public
Location: org\apache\log4j\xml\log4j.dtd in jar file C:\Development\lib\external\apache-log4j-1.2.17\log4j-1.2.17.jar
URI: jar:file:/C:/Development/lib/external/apache-log4j-1.2.17/log4j-1.2.17.jar!/org/apache/log4j/xml/log4j.dtd
Key type: Public ID
Key: -//APACHE//DTD LOG4J 1.2//EN
This references a local JAR, and supports a DOCTYPE declaration without the full URL.
<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With