Mike,

You could creat a custom logback confirm just for command line utils, logback-streamparse-cli.xml. Then set a system property either in the command line. It as the first line of your main method. 

java -Dlogback.configurationFile=/path/to/logback-streamparse-cli.xml my.MainClass

Or

public static void main() {
  System.setProperty("logback.configurationFile", pathToLogfile);
  ...
}

This way the config is picked up only for the command line utilities and not for the rest of the app. 

David

On 10 May 2014, at 01:50, Tony Trinh <tony19@gmail.com> wrote:

If your intention was to set the effective level [1] for only your loggers, you should reference your loggers by name instead of using the root logger. For example, if all your logger names begin with "backtype.storm" and you wanted only error-level messages, you would use:

  <configuration>
     <appender ... />
     <logger name="backtype.storm" level="ERROR"/>
  </configuration>

Let me know if that works for you.

[1] http://logback.qos.ch/manual/architecture.html#effectiveLevel

-Tony



On Fri, May 9, 2014 at 10:37 AM, Mike Sukmanowsky <mike@parsely.com> wrote:
Hi there,

We're currently developing project called streamparse which provides Pythonic tools for realtime stream development using Apache Storm.

Although the project is Python-based, we maintain a command line interface, written in clojure, to provide JVM/Thrift interop capabilities https://github.com/Parsely/streamparse/tree/master/jvm.

A requirement of one of our commands is to write a JSON object representation to STDOUT which our Python process would read and use downstream.  The issue we have is that Apache Storm does some logging using logback upon calling certain functions which interferes with our expectation of only JSON being written to STDOUT.

$ ./sparsej list --json
607  [main] INFO  backtype.storm.thrift - Connecting to Nimbus at localhost:6627
[{"status":"ACTIVE","num-executors":52,"name":"meta_enricher","num-workers":4,"num-tasks":52,"uptime-secs":1211495,"id":"meta_enricher-49-1398354650"},{"status":"ACTIVE","num-executors":9,"name":"visits","num-workers":4,"num-tasks":9,"uptime-secs":53668,"id":"visits-7-1399512477"},{"status":"ACTIVE","num-executors":80,"name":"ptrack","num-workers":4,"num-tasks":80,"uptime-secs":76148,"id":"ptrack-3-1399489997"}]

We added a logback-test.xml to a resources directory which is packaged with the JAR https://github.com/Parsely/streamparse/blob/master/jvm/resources/logback-test.xml.  This isn't exactly what we want though since we really only need logging suppressed for the commands we run.  What we're finding when our JAR is packaged with other dependencies is that all logging is suppressed.

How can we go about suppressing logging for a single command like https://github.com/Parsely/streamparse/blob/master/jvm/src/streamparse/commands/list.clj?

Thanks! Mike

--
Mike Sukmanowsky

Product Lead, http://parse.ly
12 W 31st Street
8th floor
New York, NY  10001

_______________________________________________
Logback-user mailing list
Logback-user@qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-user

_______________________________________________
Logback-user mailing list
Logback-user@qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-user