How to disable AspectJ dump files “ajcore.txt”

北城余情 提交于 2021-02-18 11:45:10

问题


I've got a Tomcat webapp where I'm using AspectJ for logging and metrics, everything seems fine, but it keep creating several files like ajcore.20150310.113255.780.txt in the root folder. There is no exception in this files, so they are completely useless.

I've found this: https://eclipse.org/aspectj/doc/released/pdguide/ajcore.html

That states that using org.aspectj.weaver.Dump.exception="false" should disable this behavior, yet the files are still appearing. Is there any other way to completely disable the creation of this files? The other option mentioned: org.aspectj.dump.directory would also solve the problem, but it doesn't seem to work either.

This is the content of the file in case it helps for anything:

---- AspectJ Properties --- 
AspectJ Compiler 1.7.1 built on Thursday Sep 6, 2012 at 16:39:22 GMT
---- Dump Properties --- 
Dump file: ajcore.20150310.113255.780.txt 
Dump reason: org.aspectj.weaver.BCException 
Dump on exception: true 
Dump at exit condition: abort
---- Exception Information ---
---- System Properties --- 
... My system properties here
---- Command Line --- Empty
---- Full Classpath --- Empty
---- Compiler Messages --- Empty

回答1:


Either of the following options may help:

  1. Executing this code before any AspectJ weaving occurs (if possible): org.aspectj.weaver.Dump.setDumpOnExit(org.aspectj.bridge.IMessage.ABORT)
  2. Adding this system property definition to your java command-line: -Dorg.aspectj.weaver.Dump.condition=abort



回答2:


I think it is good that the AJ core dump happens because something seems to go wrong during LTW compilation:

Dump file: ajcore.20150310.113255.780.txt 
Dump reason: org.aspectj.weaver.BCException 

So there is an exception and you should investigate and fix it. Maybe some of your classes are woven with the logging code correctly and some are not. Run the weaver in verbose mode and check your console output, maybe you see something strange there. An AJ core file means that the weaver/compiler was shut down completely (abnormal termination).

As for the actual problem, I think that this

---- Command Line --- Empty

looks strange, as if no command line parameters were passed to the weaver. Also that no exception is actually logged is really unusual.

Which Java version are you on? I assume Java 7 because 1.6 is really old and Java 8 needs AspectJ 1.8. Anyway, can you try to use the latest AspectJ version 1.8.5 or at least the latest 1.7.4 from the old release and see if the problem still occurs?



来源:https://stackoverflow.com/questions/28972701/how-to-disable-aspectj-dump-files-ajcore-txt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!