Add "filter" to "logger" for the entire application

Asked

Viewed 40 times

1

I would like to make the Filter of java.util.logging.Logger filter all generated log lines. In this case, I am using a Wildfly application server.

Currently, I can filter only one specific class, for example.

Logger logger = Logger.getLogger(Classe.class.getName());
logger.setFilter(new MeuFiltro());

That is, instead of filtering just one class, I would like to filter everything and this needs to be done programmatically, because making changes to Wildfly’s XML will not be feasible.

1 answer

0

You need to get the root logger:

Logger rootLogger = LogManager.getLogManager().getLogger("");
  • Cool, just mention it. Only, to solve for good, instead of needing Filter, I actually needed to use Handler. But anyway, your answer was part of the solution.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.