有没有办法强迫bash忽略和隐藏Cassandra警告?

时间:2016-06-02 10:40:13

标签: bash shell cassandra

基本上是title,是否有任何命令可以忽略并强制bash不打印警告,类似于python中的warnings.filterwarnings("ignore")?谢谢!

编辑:警告是WARNING: Could not connect to the JMX on localhost:8080, information won't be shown.,但它不会影响我的程序结果,因此它并不重要。

1 个答案:

答案 0 :(得分:0)

将错误重定向到/ dev / null

command-here 2>/dev/null 

(thnx @RandomUser)

将错误和输出消息重定向到日志文件

command-here > myapp.log 2>&1
> file        redirects stdout to file
> /dev/null   redirects stdout to to the null device (discards it)

1> file       redirects stdout to file
2> file       redirects stderr to file
&> file       redirects stdout and stderr to file

/dev/null is the null device it takes any input you want and throws it away.
It can be used to suppress any output.

http://www.xaprb.com/blog/2006/06/06/what-does-devnull-21-mean/

https://askubuntu.com/questions/350208/what-does-2-dev-null-mean

作为@piyushj评论,您可以尝试完全更改Cassandra日志级别。 Cassandra使用标准的Java日志库Log4j

需要编辑log4jserver.properties文件,并更改行

log4j.rootLogger=INFO,stdout,R

您可以将日志记录级别更改为INFO,DEBUG,WARN,ERROR或FATAL。

http://www.informit.com/articles/article.aspx?p=2169293