0

My question can seem quite strange but I wanted to configure my logback.xml to stop printing certain logs.

For instance, my console is polluted by a so called ERROR because a key value in a property file is duplicated. I'm aware of this problem but it's not impacting in any sorts the process. But in this case I have so many of them that I can't look at the actual logs.

I've been told to add an appender in the logback file to change the level of logs from the class and thus not printing ERROR level logs. But I don't really know how to do it.

Here is the log

14/11/2018_15:02:19.654 [main] ERROR [f.a.t.core.resources.ResourceManager] duplicated key in resources :

it's just ERROR level log from this class "f.a.t.core.resources.ResourceManager" that I don't want. Does anyone have faced a similar issue please ?

Aaron C.
  • 81
  • 1
  • 6

1 Answers1

1

Specify in your logback xml conf file the class that you want disable logs.
For example :

<logger name="fullpackage.ResourceManager" level="OFF" />

But note that is not a good practice because you will lose all potential useful error logs for this class.
The best thing would be to refactor this class (if you can) and decrease the level to INFO or below.

davidxxx
  • 125,838
  • 23
  • 214
  • 215
  • Thank you, I though it was not BP but this class is from an external library I imported so I don't have access to its source code. – Aaron C. Nov 14 '18 at 14:39
  • Thank you again David, I wanted to know if it was possible to be even more specific with that logger, can we specify just a type of error? For instance if I want the logs from that class but not those which contains the words "duplicated key" or is it not possible ? – Aaron C. Nov 14 '18 at 15:24
  • You are welcome. Of course you could use Logback filters by specifying the message to filter **out** – davidxxx Nov 14 '18 at 18:44