-
1. Re: how to deactivate logging
manik Oct 1, 2005 6:56 PM (in response to vasagotempest2)In your log4j xml file, exclude all messages generated from org.jboss.cache.* and org.jgroups.* in your appender.
-
2. Re: how to deactivate logging
vasagotempest2 Oct 3, 2005 1:05 PM (in response to vasagotempest2)I decided that severe logs may not be an issue. I have attempted to just log severe logs, however, I still get numerous logs to STDERR.
My log4j.xml:<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> <appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.SimpleLayout"/> </appender> <logger name="org.jboss.cache.*"> <level value="severe"/> </logger> <logger name="org.jgroups.*"> <level value="severe"/> </logger> <root> <priority value ="info" /> <appender-ref ref="ConsoleAppender"/> </root> </log4j:configuration>
0 [main] WARN cache.TreeCache - No transaction manager lookup class has been defined. Transactions cannot be used
16 [main] INFO cache.TreeCache - interceptor chain is:
class org.jboss.cache.interceptors.CallInterceptor
class org.jboss.cache.interceptors.LockInterceptor
class org.jboss.cache.interceptors.UnlockInterceptor
class org.jboss.cache.interceptors.ReplicationInterceptor
16 [main] INFO cache.TreeCache - cache mode is REPL_SYNC
250 [DownHandler (UDP)] INFO protocols.UDP - sockets will use interface 192.168.5.102
266 [DownHandler (UDP)] INFO protocols.UDP - socket information:
local_addr=192.168.5.102:1408, mcast_addr=230.0.0.1:2932, bind_addr=/192.168.5.102, ttl=64
sock: bound to 192.168.5.102:1408, receive buffer size=80000, send buffer size=150000
mcast_recv_sock: bound to 192.168.5.102:2932, send buffer size=150000, receive buffer size=80000
mcast_send_sock: bound to 192.168.5.102:1409, send buffer size=150000, receive buffer size=80000
-------------------------------------------------------
GMS: address is 192.168.5.102:1408
-------------------------------------------------------
2281 [main] INFO cache.TreeCache - state could not be retrieved (must be first member in group)
2281 [main] WARN cache.TreeCache - No transaction manager lookup class has been defined. Transactions cannot be used
2281 [main] INFO cache.TreeCache - interceptor chain is:
class org.jboss.cache.interceptors.CallInterceptor
class org.jboss.cache.interceptors.LockInterceptor
class org.jboss.cache.interceptors.UnlockInterceptor
2281 [main] INFO cache.TreeCache - cache mode is local, will not create the channel
service started
press enter to exit
2297 [Thread-8] INFO cache.TreeCache - viewAccepted(): new members: [192.168.5.102:1408]
2297 [Thread-8] INFO cache.TreeCache - new cache is null (maybe first member in cluster
I noticed the GMS message was not STDERR but instead STDOUT.
If I changed the root appender info to :<priority value="severe" />
I still get the same output.
Am I using Log4j incorrectly?
Is there a way to have JBossCache use an alternative logger as a workaround? -
3. Re: how to deactivate logging
manik Oct 3, 2005 2:47 PM (in response to vasagotempest2)If you are trying to suppress stdout and stderr messages, pipe these to /dev/null? Changing the logging toolkit would not help you here...
-
4. Re: how to deactivate logging
vasagotempest2 Oct 3, 2005 6:59 PM (in response to vasagotempest2)Suppressing STDERR and STDOUT is not a viable option, other parts of the application may have valid console output.
I can suppress all the STDERR messages, denoted in my previous post by italics, by disabling all commons logging.-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog
However, other parts of the application need to be able to log. I can't suppress all the log messages with this option.
I think that since I can turn off the STDERR output by turning off commons logging, that there should be a way to suppress these logs. Either with a JBossCache option, or by providing a custom Logger for JBossCache.
Is this possible? -
5. Re: how to deactivate logging
brian.stansberry Oct 3, 2005 7:55 PM (in response to vasagotempest2)RE: the WARN and INFO messages you're seeing, I don't think "severe" is a log4j level. AFAIK the valid levels are DEBUG, INFO, WARN, ERROR and FATAL. Looks like you want to limit org.jboss.cache and org.jgroups to "ERROR".
RE: the GMS message that is written to STDOUT, this can be disabled as part of the JGroups protocol stack config in the -service.xml file that configures your JBossCache. Look in the <attribute name="ClusterConfig" section for the following:<pbcast.GMS join_timeout="5000" join_retry_timeout="2000" shun="true" print_local_addr="true"/>
Change the "print_local_addr" attribute to false. -
6. Re: how to deactivate logging
vasagotempest2 Oct 4, 2005 11:41 AM (in response to vasagotempest2)Hey, thanks for the print_local_addr tip, that worked just like I wanted.
I still get the rest of the STDERR messages however, and I have changed my log4j.xml to :<appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.SimpleLayout"/> </appender> <logger name="org.jboss.cache.*"> <level value="FATAL"/> </logger> <logger name="org.jgroups.*"> <level value="FATAL"/> </logger> <root> <priority value="FATAL" /> <appender-ref ref="ConsoleAppender"/> </root>
results in :
0 [main] WARN cache.TreeCache - No transaction manager lookup class has been defined. Transactions cannot be used
0 [main] INFO cache.TreeCache - interceptor chain is:
class org.jboss.cache.interceptors.CallInterceptor
class org.jboss.cache.interceptors.LockInterceptor
class org.jboss.cache.interceptors.UnlockInterceptor
class org.jboss.cache.interceptors.ReplicationInterceptor
0 [main] INFO cache.TreeCache - cache mode is REPL_SYNC
297 [DownHandler (UDP)] INFO protocols.UDP - sockets will use interface 192.168.5.102
313 [DownHandler (UDP)] INFO protocols.UDP - socket information:
local_addr=192.168.5.102:2387, mcast_addr=230.0.0.1:2932, bind_addr=/192.168.5.102, ttl=64
sock: bound to 192.168.5.102:2387, receive buffer size=80000, send buffer size=150000
mcast_recv_sock: bound to 192.168.5.102:2932, send buffer size=150000, receive buffer size=80000
mcast_send_sock: bound to 192.168.5.102:2388, send buffer size=150000, receive buffer size=80000
2329 [Thread-20] INFO cache.TreeCache - viewAccepted(): new members: [192.168.5.102:2387]
2329 [main] INFO cache.TreeCache - state could not be retrieved (must be first member in group)
2329 [main] WARN cache.TreeCache - No transaction manager lookup class has been defined. Transactions cannot be used
2329 [main] INFO cache.TreeCache - interceptor chain is:
class org.jboss.cache.interceptors.CallInterceptor
class org.jboss.cache.interceptors.LockInterceptor
class org.jboss.cache.interceptors.UnlockInterceptor
2329 [main] INFO cache.TreeCache - cache mode is local, will not create the channel
2344 [Thread-20] INFO cache.TreeCache - new cache is null (maybe first member in cluster)
- So, even if I use log4j, I still can't get rid of these messages. Is there something wrong with my log4j configuration?
Also,
I don't want to assume that end users for this application will have log4j installed. I'd still like to go in the direction of making a custom NO-OP logger if this is possible. I just didn't see any way to extend a JBossCache logger interface or a method/constructor that sets the logger for me.
-Do I have to use Log4j?
-Is a custom logger possible? -
7. Re: how to deactivate logging
brian.stansberry Oct 4, 2005 12:48 PM (in response to vasagotempest2)Re: log4j.xml, try the following:
<appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender"> <param name="Threshold" value="FATAL"/> <layout class="org.apache.log4j.SimpleLayout"/> </appender> <category name="org.jboss.cache"> <priority value="FATAL"/> </logger> <category name="org.jgroups"> <priority value="FATAL"/> </logger> <root> <appender-ref ref="ConsoleAppender"/> </root>
I didn't test this, but it's the basic idea. I'm sure the log4j site has some docs on the proper syntax. In the JBossCache dist under the /etc directory there is a log4j.xml that you can look at as well.
Re: using other loggers:
JBossCache uses commons-logging for all logging operations. Unfortunately, in one place an import dependency on log4j snuck into the code. But the effect of this is just that log4j.jar has to be on the classpath. Otherwise you can tell commons-logging to use whatever logging framework you want, including NoOpLogger, either by putting a commons-logging.properties file on the classpath or by setting a system property.
The import dependency on log4j will be fixed in the final version of 1.2.4 (it's still there in the beta).