[
https://jira.jboss.org/jira/browse/JBLOGGING-44?page=com.atlassian.jira.p...
]
David Lloyd commented on JBLOGGING-44:
--------------------------------------
There are two issues at play here.
1) Classloader isolation. When constructing a logger instance, JDK logging looks for the
specified resource bundle in the TCCL (if it's not set, it uses the system CL); if not
found there, it will snoop up the call stack until one of the stack frame's class'
classloader contains a resource bundle with the appropriate name. If the class loader of
each WAR is not isolated, then the resource bundle called "stantest" could be
loaded from the wrong WAR. That is probably not the cause of what you're seeing
though.
2) Logger uniqueness. JDK logging only constructs one instance of each logger. If you do
Logger.getLogger(), it first checks to see if a logger of the given name already exists;
if so, it returns it (even if it is already associated with a different resource bundle).
There are two solutions to this problem. One is to use separate logger categories; this
is the simplest solution. The other solution is to set up application-scoped log contexts
by adding a jboss-logging.xml to your deployment which configures isolated logger
contexts. This will cause isolated Logger instances to be created, however the system log
handlers will not be used so you'd have to configure a separate output.
This is a hard limitation of JDK logging, unfortunately. The way they handle resource
bundles is pretty restrictive.
Logging with a ResourceBundle finds message from another WAR
------------------------------------------------------------
Key: JBLOGGING-44
URL:
https://jira.jboss.org/jira/browse/JBLOGGING-44
Project: JBoss Logging
Issue Type: Bug
Security Level: Public(Everyone can see)
Reporter: Stan Silvert
Assignee: David Lloyd
Attachments: bar.war, foo.war
I'm attaching two WARs to demonstrate. foo.war and bar.war are identical except for
the message in the resource bundle.
Hit
http://localhost:8080/foo/index.jsp
http://localhost:8080/bar/index.jsp
http://localhost:8080/foo/index.jsp
Both will output the correct message to the browser when the lookup is done from
ResourceBundle.getString(). But the log message it sends will not always be correct.
"bar" always wins. As soon as "bar" has been called then
"foo" can no longer log the correct message.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira