java - 请问如果才能打印引用的第三方jar包中方法的日志?
伊谢尔伦
伊谢尔伦 2017-04-18 10:32:17
0
4
765
  • 问题

列表项目现在问题是引用了一个第三方工具,而这个工具并没有打印日志,我想打印这个方法的的入参与返回值,注意这个方法是这个工具里面其它方法去调用的。所以入参与返回值,我是拿不到的。

  • 尝试解决

我现在想到的办法是,用spring的aop去拦截这个方法,利用环绕增强去实现。但是发现,根本拦截不了,spring貌似只能拦截他所管理的bean的方法。

想请教有没有人实现过,打印第三方jar的日志功能,谢谢

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(4)
左手右手慢动作

You can write your own logging agent class, and then use the java.lang.instrument package for bytecode injection. You can use javassist for injection, which is simple and easy to use. It is equivalent to AOP at the JVM layer.

大家讲道理

It depends on how you use it. If you use itbean对象被ioc容器管理着那一定可以使用aop

大家讲道理

Generally third-party jars have log implementation, which may use commons-logging or slf4j interface. For example, if slf4j is used to implement logback, then it is generally sufficient to add slf4j and logback jars to the project. To change the log implementation method, use log Bridge package.
If the requirements cannot be met, you can use jd-dui to decompile and jbe to modify the bytecode

巴扎黑

I just found a tool, anylog, which seems to work, but I haven’t tried it yet, but it would be best to implement it through code. I’m still looking for a way

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!