logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 23224] New: - cannot use NTEventLogAppender in multiple classloaders (webapps)
Date Wed, 17 Sep 2003 19:05:35 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23224>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23224

cannot use NTEventLogAppender in multiple classloaders (webapps)

           Summary: cannot use NTEventLogAppender in multiple classloaders
                    (webapps)
           Product: Log4j
           Version: 1.2
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Appender
        AssignedTo: log4j-dev@jakarta.apache.org
        ReportedBy: jmm@sublogic.com


single Tomcat running, multiple webapps, each of which has their own log4j and 
wants to use NTEventLogAppender.

The problem is that the class loads its native library without try/catch'ing, 
so when any classloader besides the first attempts to load the library (as part 
of its classloader loading the NTEventLogAppender class file itself), there's 
an exception and the logging fails.

so, the end of NTEventLogAppender.java is now:

  static {
    System.loadLibrary("NTEventLogAppender");
  }

That would be better with a try/catch of the loadLibrary so then the other 
webapps could load the class and use it.  Note that the system classloader is 
where the library is actually loaded, so the other classloaders should have 
access to it just fine.

  static {
    try {
      System.loadLibrary("NTEventLogAppender");
    } catch (Throwable t) {}
  }

(would prob. wanna replace Throwable with whatever the specific type of 
exception is that's thrown for the second-and-later classloaders, I don't have 
my logs around to check any more).

Alternative work-around is to use something System-wide (outside of the 
individual classloaders) like a System property:

  static {
    if(System.getProperty("NTEventLogAppender.loaded") == null) {
      System.loadLibrary("NTEventLogAppender");
      System.setProperty("NTEventLogAppender.loaded", "true");
    }
  }

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org


Mime
View raw message