--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/d9eeecd4-0c6e-4c1e-b7a5-873ee590b10c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
package myApp;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.logging.Filter;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import java.io.File;
public class VertxLogFilter implements Filter
{
private final String FILTER = "forcibly closed by the remote";
private final String CLASS = "io.vertx.core.net.impl.ConnectionBase";
@Override
public boolean isLoggable(LogRecord record)
{
if (record == null)
{
return false;
}
String loggerName = record.getLoggerName();
if (loggerName.equals(CLASS))
{
String message = record.getMessage();
if (message != null)
{
if (message.contains(FILTER))
{
return false;
}
return true;
}
return false;
}
return true;
}
public static void init(Level level)
{
Logger rootLogger = Logger.getLogger("");
for (Handler handler : rootLogger.getHandlers())
{
handler.setLevel(level);
handler.setFilter(new VertxLogFilter());
}
rootLogger.setLevel(level);
}
public static void init()
{
File file = new File("config/logger.properties");
if (file.exists())
{
fileInit();
} else
{
init(Level.WARNING);
}
}
/**
* Loads from file
* Example config/logger.properties file:
* handlers=java.util.logging.ConsoleHandler
* .level=WARNING
* java.util.logging.ConsoleHandler.level=WARNING
* java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
* java.util.logging.ConsoleHandler.filter=myApp.VertxLogFilter
*/
public static void fileInit()
{
LogManager logManager = LogManager.getLogManager();
try
{
logManager.readConfiguration(new FileInputStream("config/logger.properties"));
} catch (IOException exception)
{
System.err.println("Error loading config/logger.properties");
}
}
}