Hi,

It would be really nice to have a command-line method for setting the log
level on a running broker (c++), as discussed here:
http://grokbase.com/t/qpid/users/11bxbmbxq3/set-log-level

The suggested solution with qpid-ctrl tool does work, but since this is, as
mentioned in the article, a test tool and also doesn't support ssl
connections, it doesn't quite fit the bill for many scenarios.

Would it be possible to add this feature to qpid-config, which already has
almost everything that's required in place? I've attached a patch to
qpid-tools-0.32 which fulfils at least my wishes - as you can see only a
handful of actual code lines.

Regards
-- 

*Chris Richardson*, System Architect
c...@fourc.eu


*FourC AS, Vestre Rosten 81, Trekanten, NO-7075 Tiller, Norwaywww.fourc.eu
<http://www.fourc.eu/>*

*Follow us on LinkedIn <http://bit.ly/fourcli>, Facebook
<http://bit.ly/fourcfb>, Google+ <http://bit.ly/fourcgp> and Twitter
<http://bit.ly/fourctw>!*
diff -ur qpid-tools-0.32/src/py/qpid-config qpid-tools-0.32-loglevel/src/py/qpid-config
--- qpid-tools-0.32/src/py/qpid-config	2015-02-11 20:43:53.000000000 +0000
+++ qpid-tools-0.32-loglevel/src/py/qpid-config	2016-01-20 16:51:36.508006692 +0000
@@ -48,6 +48,8 @@
         qpid-config [OPTIONS] add <type> <name> [--argument <property-name>=<property-value>]
         qpid-config [OPTIONS] del <type> <name>
         qpid-config [OPTIONS] list <type> [--show-property <property-name>]
+        qpid-config [OPTIONS] get-loglevel
+        qpid-config [OPTIONS] set-loglevel <level>
         qpid-config [OPTIONS] shutdown"""
 
 description = """
@@ -57,6 +59,7 @@
 $ qpid-config add exchange direct d -a localhost:5672
 $ qpid-config exchanges -b 10.1.1.7:10000
 $ qpid-config queues -b guest/guest@broker-host:10000
+$ qpid-config set-loglevel trace+:Security
 
 Add Exchange <type> values:
 
@@ -78,6 +81,14 @@
     none           - no replication
     configuration  - replicate queue and exchange existence and bindings, but not messages.
     all            - replicate configuration and messages
+
+Log levels:
+    A log level is a set of comma-separated rules, where a rule is in the form 'LEVEL[+-][:PATTERN]'.
+    LEVEL is one of: trace debug info notice warning error critical
+    PATTERN is a logging category name, or a namespace-qualified function name or name fragment.
+    Logging category names are:
+        Security Broker Management Protocol System HA Messaging Store
+        Network Test Client Application Model Unspecified
 """
 
 REPLICATE_LEVELS= ["none", "configuration", "all"]
@@ -611,7 +622,7 @@
             declArgs[r[0]] = get_value(r)
 
         if config._durable:
-            # allow the default fileCount and fileSize specified 
+            # allow the default fileCount and fileSize specified
             # in qpid config file to take prededence
             if config._fileCount:
                 declArgs[FILECOUNT] = config._fileCount
@@ -666,8 +677,6 @@
             Usage()
         qname = args[0]
         self.broker.delQueue(qname, if_empty=config._if_empty, if_unused=config._if_unused)
- 
-
 
     def Bind(self, args):
         if len(args) < 2:
@@ -716,6 +725,12 @@
             key = args[2]
         self.broker.unbind(ename, qname, key)
 
+    def GetLogLevel(self):
+        print self.broker.getLogLevel()['level']
+
+    def SetLogLevel(self, level):
+	self.broker.setLogLevel(level)
+
     def ReloadAcl(self):
         try:
             self.broker.reloadAclFile()
@@ -798,6 +813,13 @@
                 bm.Unbind(args[1:])
             elif cmd == "reload-acl":
                 bm.ReloadAcl()
+            elif cmd == "get-loglevel":
+                bm.GetLogLevel()
+            elif cmd == "set-loglevel":
+                if modifier != "":
+                    bm.SetLogLevel(modifier)
+                else:
+                    Usage()
             elif cmd == "list" and len(args) > 1:
                 # fetch objects
                 objects = bm.broker.list(modifier)
diff -ur qpid-tools-0.32/src/py/qpidtoollibs/broker.py qpid-tools-0.32-loglevel/src/py/qpidtoollibs/broker.py
--- qpid-tools-0.32/src/py/qpidtoollibs/broker.py	2014-06-02 14:56:12.000000000 +0100
+++ qpid-tools-0.32-loglevel/src/py/qpidtoollibs/broker.py	2016-01-20 15:40:19.955012325 +0000
@@ -222,7 +222,7 @@
 
   def getLogLevel(self):
     """Get the log level"""
-    return self._method('getLogLevel')
+    return self._method('getLogLevel', {})
 
   def setTimestampConfig(self, receive):
     """Set the message timestamping configuration"""
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@qpid.apache.org
For additional commands, e-mail: users-h...@qpid.apache.org

Reply via email to