如何停止NioProcessor的日志记录?
Got it, those repetitive NioProcessor logs from MINA's LoggingFilter can be super annoying. Let's fix that right away!
First, let's clarify: those logs are coming from org.apache.mina.filter.logging.LoggingFilter, which defaults to logging connection lifecycle events (like CREATED, OPENED, CLOSED) at the INFO level. To mute these, you just need to adjust the logging level for this specific class in your logging framework configuration.
Here are the most common solutions based on the logging framework you're using:
1. If you're using Logback (Spring Boot's default)
Option 1: Update logback.xml or logback-spring.xml
Add a logger configuration specifically for the LoggingFilter class to raise its log level (so INFO messages get ignored):
<configuration> <!-- ... your existing config ... --> <logger name="org.apache.mina.filter.logging.LoggingFilter" level="WARN" additivity="false"> <appender-ref ref="YOUR_APPENDER_NAME"/> </logger> </configuration>
Setting the level to WARN will only let through warning and error messages. If you want to silence it completely, use OFF instead.
Option 2: Use Spring Boot's application properties
If you're using Spring Boot, you can add this line directly to application.properties:
logging.level.org.apache.mina.filter.logging.LoggingFilter=WARN
Or in application.yml:
logging: level: org.apache.mina.filter.logging.LoggingFilter: WARN
2. If you're using Log4j2
Update your log4j2.xml to include a logger for the LoggingFilter:
<Configuration> <!-- ... your existing config ... --> <Logger name="org.apache.mina.filter.logging.LoggingFilter" level="WARN" additivity="false"> <AppenderRef ref="YOUR_APPENDER_NAME"/> </Logger> </Configuration>
Again, use OFF if you want to stop all logs from this class entirely.
3. (Alternative) Adjust via code (not recommended for production)
If you need a quick code-based fix (though configuration files are better for maintainability), you can set the log level programmatically:
import org.slf4j.LoggerFactory; import ch.qos.logback.classic.Logger; // For Logback Logger logger = (Logger) LoggerFactory.getLogger("org.apache.mina.filter.logging.LoggingFilter"); logger.setLevel(ch.qos.logback.classic.Level.WARN);
That should get rid of those pesky NioProcessor connection status logs.
内容的提问来源于stack exchange,提问作者cathy Chou

