Frage

Scenario : I have an application where we noticed some unnecessary logging due to which the memory usage on that server goes upto 90% which is not desirable at all and a concern for the prod support . The culprit is a class where I have bunch of logging statements such as log.info and in the prod environment I don't have access to this class but I have access to the spring config xml. Can I apply an aspect to the class/in particular a method to stop executing the log.info statements?

War es hilfreich?

Lösung

I agree to the comments right below your question: Just reconfigure logging.

Technically speaking, with Spring AOP you are limited to intercepting calls to or executions of Spring bean methods. So unless your logging calls are not encapsulated in Spring beans, Spring AOP will not be useful.

With AspectJ though, you could apply LTW (load-time weaving) to your logging library and block execution of logging methods called by a specific control flow. You could also do the same by weaving your application code and then block calls to logging methods from within a specific control flow.

Disclaimer: While this is easily implemented aspect-wise, I have no idea if your production admins will permit you to use AspectJ on the target system. Even if you compile the aspects into your own production code, at least you will need the AspectJ runtime (aspectjrt.jar) on the application's classpath.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top