0

Related to this question. It appears that Glassfish is exporting slf4j into my application and overriding my logging solution. Is it possible for me to override Glassfish's logging and have my own logging solution take precedence? After searching, I have only found ways to modify the log using logging.properties.

I am not married to my current implementation, but I am interested in making it work.

thanks.

Community
  • 1
  • 1
kgrad
  • 4,672
  • 7
  • 36
  • 57
  • 1
    I am quite interested in this question. However, if the GFv3 developers don't hang on StackOverflow, you won't be getting a response. – Ceki Mar 11 '10 at 08:58
  • @Ceki Well, I suggested to leave a comment in this thread http://forums.java.net/jive/message.jspa?messageID=379334. At least, you would catch Sahoo's attention. – Pascal Thivent Mar 13 '10 at 00:47
  • It appears that applications running under GlassFish 3.0.1 does not see the container slf4j classes. – Thorbjørn Ravn Andersen Sep 29 '10 at 09:06

2 Answers2

1

As suggested in the other answer, try to configure GlassFish to use firstly the child classloaders before to delegate. In the sun-web.xml:

<sun-web-app>
  <class-loader delegate="false"/>
</sun-web-app>

But if this works, this is more a workaround that a real solution, your application shouldn't be polluted by the SLF4J bindings of bean-validation.jar and weld-osgi-bundle.jar (at least I believe so). You should maybe raise an issue.

Update: For the archives, the suggested workaround doesn't work. But I couldn't reproduce the issue.

Community
  • 1
  • 1
Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
  • @krad I don't understand why this does not work. But thanks for the feedback. You should raise an issue IMHO. – Pascal Thivent Mar 15 '10 at 16:27
  • @Pascal Thivent - I brought it to the attention of #Glassfish on freenode, I believe some people are testing it out. The only thing I have heard so far is "it's likely a classloader order issue". – kgrad Mar 15 '10 at 17:24
  • @krad Well, that's the obvious part :) – Pascal Thivent Mar 15 '10 at 17:25
  • @Pascal Thivent - I have reported the issue: https://glassfish.dev.java.net/issues/show_bug.cgi?id=11683 – kgrad Mar 15 '10 at 17:50
  • @kgrad Thank you very much for the feedback. Have a look at http://stackoverflow.com/questions/2418069/logback-with-ejb3-1/2418355#2418355, I've updated my answer. – Pascal Thivent Mar 16 '10 at 01:03
0

The short answer is, Glassfish does some nasty logger tweaking, redirecting System.out and System.err to its own log. I did not manage to stop it doing so, but I found a way to collect all server and application log messages in a single slf4j log by placing the slf4j libs early enough in the classpath and editing the logging.properties of Glassfish.

For the long answer, see this blog post.

Harald Wellmann
  • 12,615
  • 4
  • 41
  • 63