Yes, this can be done. (I am assuming you are using Java, correct?)
You can activate the IllegalImport check from the Checkstyle repository in your Java quality profile. Make sure to add org.apache.log4j
to the list of illegalPkgs
. E.g. set illegalPkgs
to sun, com.sun, org.apache.log4j
.
Also, in SonarQube, you can activate the Architectural Constraint rule. Here, you must set the toClasses
property to a wildcard expression such as org.apache.log4j.**
.