Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable logs in Netty 4?

How can I disable all logs Netty 4 does with log4j? I actually want to write all logs by myself and see only in logs only what I wrote there. I'm new to both Netty and log4j.

like image 948
DWand Avatar asked Dec 22 '13 22:12

DWand


2 Answers

It looks like the line listed below helped me to turn off Netty logs. I don't know if it disables all possible logs from Netty, but at least those I'd already saw.

Logger.getLogger("io.netty").setLevel(Level.OFF);
like image 190
DWand Avatar answered Sep 20 '22 07:09

DWand


The answer by @DWand did not work for me, but something similar did work in the case of Hibernate:

Logger.getLogger("org.hibernate").setLevel(...)

For Netty, I simply used a class-based config, and set a name filter to the log handler along with some other conditions:

handler.setFilter(record -> !record.getLoggerName().startsWith("io.netty"))

I am not sure if this is a good way to do it, but this was the only way I could skip only Netty logs.

like image 39
Ruraj Avatar answered Sep 19 '22 07:09

Ruraj