Error message should be surpressed when running test
oza opened this issue · 3 comments
oza commented
RawSocketSender#open
shows the exception when RawSocketSender
fails to connect to server. The behaviour itself has no problem. However, it can confuses us when testing. We can set Level.OFF
as an additional argument of RawSocketSender
for testing.
The log is as follows:
Running org.fluentd.logger.sender.TestRawSocketSender
2013/09/05 23:11:36 org.fluentd.logger.sender.RawSocketSender open
fatal: Failed to connect fluentd: localhost/127.0.0.1:25227
2013/09/05 23:11:36 org.fluentd.logger.sender.RawSocketSender open
fatal: Connection will be retried
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)
at org.fluentd.logger.sender.RawSocketSender.connect(RawSocketSender.java:89)
at org.fluentd.logger.sender.RawSocketSender.open(RawSocketSender.java:77)
at org.fluentd.logger.sender.RawSocketSender.<init>(RawSocketSender.java:72)
at org.fluentd.logger.sender.RawSocketSender.<init>(RawSocketSender.java:60)
at org.fluentd.logger.sender.RawSocketSender.<init>(RawSocketSender.java:56)
at org.fluentd.logger.sender.TestRawSocketSender.testNormal03(TestRawSocketSender.java:134)
xerial commented
The log messages are now reduced to shorter ones, by setting Formatter in java.util.logging and embedding stack traces to log messages instead of using printStackTrace()
.
Running org.fluentd.logger.sender.TestRawSocketSender
2013-12-13 10:07:55 SEVERE org.fluentd.logger.sender.RawSocketSender open Failed to connect fluentd: localhost/127.0.0.1:42777
2013-12-13 10:07:55 WARNING org.fluentd.logger.sender.RawSocketSender open Connection will be retried
2013-12-13 10:07:57 SEVERE org.fluentd.logger.sender.RawSocketSender open Failed to connect fluentd: /192.0.2.1:24224
2013-12-13 10:07:57 WARNING org.fluentd.logger.sender.RawSocketSender open Connection will be retried
oza commented
LGTM. Can you create branch in your repository and create a pull request?