0

We are running are a series JAX-WS webservices and I'm currently trying to improve the applications logging.

I am currently failing to find a way to capture Runtime exceptions so they can be logged with stacktrace etc. With the hope that we don't have to have to wrap each of our functions in a try/catch to facilitate the logging.

It appeared that the web service handlers are too late.

It feels like this should be well tread ground but my googling is not feeding me the results I need. Has anyone got any ideas about how best to achieve this, feeling stuck.

Thanks, Jon

Jon Whitefield
  • 191
  • 1
  • 1
  • 15

1 Answers1

1

You can try AOP here . Create a @annotation and make that particular annotation as an pointcut in AOP. And write around function so that you can log whatever you want around the execution. The only thing you have to do is to provide annotation to the function.

You can check this : https://www.baeldung.com/spring-aop-annotation

Rahul Anand
  • 165
  • 7
  • Thank you Rahul you are my favorite person of the day!!! I have had quite a steep learning curve today but my initial test has been very useful. – Jon Whitefield Mar 04 '20 at 17:00
  • As it seems you have some knowledge in the area if you could nudge me in the right one time. I am using the @Around to do what I need however I am pointing this to a class using "execution(public * ..*(..))" however I have methods which are void and some objects, arrays, primitives etc. As you have to have a concrete method do I have to define an Around function for all possible return types e.g. public void voidArround(ProceedingJoinPoint joinPoint), public Object returnArround(ProceedingJoinPoint joinPoint) – Jon Whitefield Mar 04 '20 at 17:46
  • I used the @AfterThrowing for something else which is very useful! – Jon Whitefield Mar 04 '20 at 17:46