gamo
gamo

Reputation: 1577

Disable logger in class called by other class

I'm facing a problem with schedule job logging.

I have a class called A here is a schedule job run every minute.

Inside A call to class B where I placed some logical method and have some log inside B and B also called by some other class that not A.

Is there anyway I can disable log in B that called from A but not the other with log4j?

Upvotes: 0

Views: 519

Answers (1)

ma3stro
ma3stro

Reputation: 313

It doesn't matter whether the method has been called from another class or not. You just declare a Logger variable in every class and modify their log level.

You can add below line into your log4j properties file

log4j.logger.<package.class> = OFF

or you can do it inside the code

Logger.getLogger("package.class").setLevel(Level.OFF);

Upvotes: 1

Related Questions