How to change log levels

I’d like to suppress all the

INFO - LoggingAdvice.invoke(115) |2019-01-08 14:16:42,270| In method AlertService.saveAlert. Arguments: Alert=Alert: #null,
INFO - LoggingAdvice.invoke(155) |2019-01-08 14:16:42,272| Exiting method saveAlert

in my logs. LoggingAdvice.java makes it look like the relevant class I need to set the log level for is org.openmrs.api. Does anyone know how to set the logging level for a class? Is that indeed the way to quiet down LoggingAdvice?

1 Like

Is this of help : Change OpenMRS log level

1 Like

This is an oldie but goodie :slight_smile: Looks like I created a ticket asking for this around 7 years ago - how time flies!

@burke / @dkayiwa is there any good reason for us not to have LoggingAdvice use it’s own logger that can be selectively controlled? I’ve never understood this.

That looks like it changes the global log level. I’d like to change it on a per-module basis. LoggingAdvice posts those “In method…” / “Exiting method…” messages to info (which I think is not a great choice — logs at that resolution should be at level debug at the very highest, probably better trace). I’d like info to be usable.

@mseaton, do you know how to adjust log levels for specific classes? I’d be happy just changing the level for org.openmrs.api, for the moment.

@bistenes, I believe that changing the global property as described above would accomplish that.

You could also:

  • modify log4j.xml directly in the webapp
  • use the logmanager module (assuming this still works)

It might be possible to simply override the root logger in a log4j.xml file defined within your module’s resources. You should also be able to modify in code I think. Something like:

Logger logger = LogManager.getLogger(Xyz.class);
logger.setLevel(Level.TRACE);

But fundamentally, whichever you choose, I’m not sure there is any way to turn off the annoying logging around these service methods without affecting all logging for classes within the org.openmrs.api packages or subpackages. I could be wrong.

Mike