-
Notifications
You must be signed in to change notification settings - Fork 181
faq 111411605
by Robert Fitzgerald on 2017-08-18 00:13:51
Hi!
I'm working with the MATSim library and want to suppress INFO logging. Is there a way to access Config's log4j instance and set it's log level? Right now I am using the following work-around in my driver class:
Logger.getRootLogger.setLevel(Level.WARN)
But, with this solution, I can't use my own logger to issue INFO related to my experiments.
Thank you for reading,
Rob
by Marcel Rieser on 2017-08-18 07:30:24
By default, each class in MATSim uses it's own Logger, so that it's level can be set individually.
In your code, you change the level of the root logger which is used by default for all classes. To change the settings just for a single class, e.g. Config, you can use the following code:
Logger.getLogger(Config.class).setLevel(Level.WARN);
In the log file, the class name is typically shown after the log level. Example:
2017-08-18 09:27:53,264 INFO MatsimXmlParser:155 starting to parse xml from url ....
This line shows that the logger responsible for this line is the class `MatsimXmlParser`. So to configure the logger responsible for this line, you could use
Logger.getLogger(MatsimXmlParser.class).setLevel(Level.WARN);
You are viewing an archive of the previous MATSim Q&A site. The real site is now at https://matsim.org/faq