8 Replies Latest reply on Dec 12, 2009 6:14 PM by gavin.king

    Inject Logger from slf4j

      Hi,


      I can only inject the org.slf4j.Logger into a stateless-bean because org.slf4j.Logger doesn't implement java.io.Serializable.


      Any ideas how I could solve that problem?


      Alex

        • 1. Re: Inject Logger from slf4j

          BTW do anybody know where the logging-config is located in JBoss 6.0 M1?
          I cannot find it because in directory ../server/default/conf there isn't a jboss-logging-config.


          Alex

          • 2. Re: Inject Logger from slf4j

            Maybe the transient keyword can help you?

            • 3. Re: Inject Logger from slf4j
              dan.j.allen

              Is server/default/conf/jboss-log4j.xml what you are looking for? Or are you looking for control over which logging framework is used? Best to ask over here: JBoss AS user forums

              • 4. Re: Inject Logger from slf4j
                dan.j.allen

                The transient keyword is not sufficient because it's not OK if injected loggers just disappear after passivation. As Gavin suggests on the mailinglist, we need to support injection into static fields to solve this type of problem.


                The other solution, I believe, is to injected a scoped logger so that you get a proxy rather than a hard reference.

                • 5. Re: Inject Logger from slf4j

                  @Dan
                  thanks.
                  Injection into static field would be great.
                  Regarding the log4j config. Hmm ok I expected the jboss-log4j.xml in /server/default/conf but I cannot find it. Probably I have to download a new Build of AS6.0 becaus I've got a snapshot before M1.


                  As long as injection into static field is not support I'm gonna create my logger via plain instatiation.


                  Thanks Alex

                  • 6. Re: Inject Logger from slf4j
                    dan.j.allen

                    Definitely go for M1. It is the most reliable release (I guess that's why it is a milestone, hehehe)


                    As I always say, do what makes you productive. If @Logger is causing you problems, don't fight against the grain right now. For your own work, just instantiate it. You won't lose a toe. If you are interested in helping w/ the idea for static field injection, or impl, then we invite you to jump in there as well ;)

                    • 7. Re: Inject Logger from slf4j
                      cgulcu

                      Although the Logger interface does not extend java.io.Serializable, all Logger implementations which ship with SLF4J do implement java.io.Serializable. I am quite surprised to learn that Logger serialization is causing problems. Could you provide more details on what you are trying to do and how that fails? BTW, which logging framework are you using?

                      • 8. Re: Inject Logger from slf4j
                        gavin.king

                        Yes, please post the exception stack trace. It might actually be a bug in Weld.