1 Reply Latest reply on Nov 6, 2008 2:59 PM by Tom N

    IllegalAccessError when trying to implement custom log4j in

    Mike Kushner Newbie

      Hi, I'm running a project where I'd like to modify the log4j configuration without having to go in and modify the server's jboss-log4j.xml file manually. I found a guide on the JBoss wiki (http://wiki.jboss.org/wiki/Wiki.jsp?page=Log4jRepositorySelector) where the EJB section seems to do exactly what I'd like, so I've tried implementing it. Through some debugging work, I've figured out that the line

      private static Object guard = LogManager.getRootLogger();


      throws the following exception:

      java.lang.IllegalAccessError: tried to access field org.apache.log4j.Priority.level from class org.apache.log4j.Hierarchy
      at org.apache.log4j.Hierarchy.setThreshold(Hierarchy.java:171)
      at org.apache.log4j.Hierarchy.(Hierarchy.java:82)
      at org.apache.log4j.LogManager.(LogManager.java:69)
      (...)


      I can't quite figure out why the code from the wiki doesn't work with my project, so I must be seriously missing something here?
      If there is some inherant reason for why this shouldn't work, does anybody know a workaround?

      My first post here, so please excuse any faux pas. Thanks for your time
      /Mike

        • 1. Re: IllegalAccessError when trying to implement custom log4j
          Tom N Newbie

          -- Bump

          I'm seeing this same problem; albeit for a slightly different reason. I'm using SLF4J-log4j, which seems like it's attempting to set the priority. Here's the relevant stacktrace bits:

           java.lang.IllegalAccessError: tried to access field org.apache.log4j.Priority.level from
          class org.apache.log4j.Hierarchy
           at org.apache.log4j.Hierarchy.setThreshold(Hierarchy.java:180)
           at org.apache.log4j.Hierarchy.<init>(Hierarchy.java:91)
           at org.apache.log4j.LogManager.<clinit>(LogManager.java:78)
           at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:73)
           at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:178)
          


          Thanks in advance.