-
1. Re: log4j and JMS appender
genman Jul 16, 2005 4:05 PM (in response to kookywon)There should be a "LoggingService" deployed someplace in jboss-service.xml . You can add a .. to it so it waits for the ConnectionFactory to be bound.
It is a fine solution, but you won't get any logging until JMS is started. Alternatively, you could create your own JMX service that adds a new appender to Log4J programmatically.
You'd do something like this in your startService() :
JMSAppender a = new JMSAppender();
... configure
Logger.getRootLogger().addAppender(a); -
2. Re: log4j and JMS appender
kookywon Jul 19, 2005 10:48 AM (in response to kookywon)You said:
"There should be a "LoggingService" deployed someplace in jboss-service.xml . You can add a .. to it so it waits for the ConnectionFactory to be bound. "
what exactly do I add? Could you post some example code?
My current log4j entry looks like this:<mbean code="org.jboss.logging.Log4jService" name="jboss.system:type=Log4jService,service=Logging"> <attribute name="ConfigurationURL">resource:log4j.xml</attribute> <!-- Set the org.apache.log4j.helpers.LogLog.setQuiteMode. As of log4j1.2.8 this needs to be set to avoid a possible deadlock on exception at the appender level. See bug#696819. --> <attribute name="Log4jQuietMode">true</attribute> </mbean>
What should it look like after your suggested change? -
3. Re: log4j and JMS appender
genman Jul 20, 2005 12:25 AM (in response to kookywon)I meant to post ... add a
<depends>jboss.mq.destination:service=Queue,name=XX</depends>
but the JBoss forum ate the XML. -
4. Re: log4j and JMS appender
kookywon Jul 21, 2005 4:10 PM (in response to kookywon)I added this depends statement to my Log4JService mbean code:
<depends>jboss.mq.destination:service=Topic,name=CSEEventLogServiceQueue</depends>
which comes from the jbossmq-destinations-service.xml and is the topic for my JMS appender.
However, I'm still getting this error:14:07:06,562 INFO [Log4jService$URLWatchTimerTask] Configuring from URL: resource:log4j.xml log4j:ERROR Could not find name [java:/ConnectionFactory]. log4j error: Error while activating options for appender named [JMS]. javax.naming.NameNotFoundException: ConnectionFactory not bound
Am I using the wrong mbean in the depends statement? -
5. Re: log4j and JMS appender
genman Jul 22, 2005 6:12 PM (in response to kookywon)
Try adding "jboss.mq:service=InvocationLayer,type=JVM" as well. -
6. Re: log4j and JMS appender
kookywon Jul 25, 2005 12:52 PM (in response to kookywon)I've updated my jboss-service.xml to look like this:
<mbean code="org.jboss.logging.Log4jService" name="jboss.system:type=Log4jService,service=Logging"> <attribute name="ConfigurationURL">resource:log4j.xml</attribute> <!-- Set the org.apache.log4j.helpers.LogLog.setQuiteMode. As of log4j1.2.8 this needs to be set to avoid a possible deadlock on exception at the appender level. See bug#696819. --> <attribute name="Log4jQuietMode">true</attribute> <!-- setting depends for JMS --> <depends>jboss.mq.destination:service=Topic,name=CSEEventLogServiceQueue</depends> <depends>jboss.mq:service=InvocationLayer,type=JVM</depends> </mbean>
However, I'm still getting this error:10:50:44,187 INFO [Log4jService$URLWatchTimerTask] Configuring from URL: resource:log4j.xml log4j:ERROR Could not find name [java:/ConnectionFactory]. log4j error: Error while activating options for appender named [JMS]. javax.naming.NameNotFoundException: ConnectionFactory not bound at org.jnp.server.NamingServer.getBinding(NamingServer.java:490) at org.jnp.server.NamingServer.getBinding(NamingServer.java:498) at org.jnp.server.NamingServer.getObject(NamingServer.java:504) at org.jnp.server.NamingServer.lookup(NamingServer.java:277) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:530)
-
7. Re: log4j and JMS appender
genman Jul 25, 2005 1:37 PM (in response to kookywon)
You might need to separate the logging service into its own -service.xml file and put it in the deploy dir. I don't know if the boot jboss-service.xml does dependency checking or not. -
8. Re: log4j and JMS appender
kookywon Jul 25, 2005 6:32 PM (in response to kookywon)hmmm....that's not doing it either. I removed my log4j entry, put it in a file called log4j-services.xml in the deploy directory. I get the exact same error on startup. I confirmed that jboss-service.xml has no log4j entry. I updated the log4j.xml file (jboss reloaded it) and now the logging works.
So, having the log4j-service.xml file in the deploy directory doesn't change the log4j functionality. I'm getting the message in my topic like expected. It has to be another dependency. Unfortunately, I'm unfamiliar with the dependencies. The two I have (one for the topic and one for the invocation layer) aren't fixing the problem. -
9. Re: log4j and JMS appender
kookywon Aug 4, 2005 1:17 PM (in response to kookywon)I still haven't solved this problem. Does anyone else have any idea? Is there a better forum to post this question on?
-
10. Re: log4j and JMS appender
adrian.brock Aug 4, 2005 1:35 PM (in response to kookywon)It is an extremely bad idea (as I've already discussed in earlier posts).
JBossMQ uses log4j internally so you are just going to get loops and deadlocks
in the logging.
logger -> appenders -> jbossmq -> logger -> appenders -> jbossmq
and
appender -> logger is a deadlock situation in log4j
Is there a better forum to post this question on?
The log4j list. I know Ceki was working on a fix for the deadlock issue a while ago. -
11. Re: log4j and JMS appender
genman Aug 5, 2005 6:19 PM (in response to kookywon)
I was working on solving that little deadlock issue about a year, since I've run into it before. It looks like 1.3 will be deadlock prone as well because of how they do their lock ordering, but at least it should be more safe.
Assuming you don't add the JMS appender to the org.jboss category you ought to be mostly safe.
The appenders (in 1.2 and 1.3) themselves have loop guards to prevent them from being called recursively, so I don't know if Adrian's fear is justified.