4

On startup JGroups 2.7.0. GA writes to System.out a message along the lines of:

---------------------------------------------------------
GMS: address is 10.0.3.35:48641 (cluster=blabla)
---------------------------------------------------------

I want to either suppress it or redirect it using Log4j ( which the rest of the framework uses ).

Ideas?


I don't want to redirect System.out by itself since that usually causes more trouble than it's worth.

Robert Munteanu
  • 67,031
  • 36
  • 206
  • 278

3 Answers3

4

You can suppress the printing of the GMS address by setting in your XML

<pbcast.GMS print_local_addr="false" ...>

Works on JGroups 2.5.1 as well.

1

This is how i managed to do print GMS string to logs.

First disable

<pbcast.GMS print_local_addr="false"> 

then,

String clusterName = channel.getClusterName();
String clusterAddress = channel.getAddressAsString();
String localAddress = channel.getProtocolStack()
        .dumpStats()
        .get("UDP")
        .get("local_physical_address")
        .toString();

StringBuilder border = new StringBuilder();
String GMS = String.format("GMS: address=%s, cluster=%s, physical address=%s", 
        clusterAddress, 
        clusterName, 
        localAddress
);
logger.info("{}", GMS);

Works with 4.2.3.Final version.

WhiteScars
  • 121
  • 1
  • 5
0

You can't redirect System.out to log4j that makes no sense. After all how would log4j print anything ? It would get stuck in a loop.

mP.
  • 18,002
  • 10
  • 71
  • 105
  • Thanks for the answer. What I meant was not redirecting System.out - I specified that, but redirect that single JGroups message. – Robert Munteanu Jun 19 '09 at 12:38
  • There is some shenanigans going on with STDOUT in JBoss. When you print something to System.out, you get a log entry in the log4j log like "15:32:51,919 [] INFO [STDOUT] blah blah". So *something* is redirecting stdout and assigning it to a dedicated log4j category. – skaffman Jun 19 '09 at 14:55
  • @Skaffman What i meant is since the original real undecorated handle to Sysout is wrapped its a mess to attempt to capture Sys.out prints. After all where would you print them - to itself which result in that being caught again - etc... it doesnt end. If you had the original Sysout then one could do whatever. Its not hard to capture Sysout prints simply replace the original but its important to keep a handle on the original so you can print to it when you so wish. – mP. Jun 19 '09 at 22:31