You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

trace.adoc 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. [[trace]]
  2. = Tracing
  3. [[trace-introduction]]
  4. == Introduction
  5. The AspectJ developers have instrumented the compiler/weaver with many
  6. "trace" messages for their own debugging use. These remain in the
  7. production releases because tracing helps when it is hard to isolate the
  8. problem in a test case. This sections describes how to enable tracing so
  9. you can provide trace information on bug reports.
  10. The usual approach to opening a report on Bugzilla is to describe the
  11. symptoms of the problem and attach a simple testcase. This allows the
  12. AspectJ team to try and reproduce the problem in an attempt to fix it as
  13. well as improve the test suite. Unfortunately it may not be possible to
  14. produce such a testcase either because your program is too large or is
  15. commercially sensitive. Alternatively the problem may relate to your
  16. specific environment where AspectJ is being used and will not be
  17. reproducible by the AspectJ team. In each of these situations you can
  18. produce a trace of the compiler when the problem occurs instead. This
  19. can then be attached to the bug report.
  20. [[trace-configuration]]
  21. === Configuring Tracing
  22. When available (Java 5 or later) AspectJ will use the
  23. http://java.sun.com/j2se/1.5.0/docs/guide/logging/index.html[java.util.logging]
  24. infrastructure configured using a `logging.properties` file. By default
  25. only error and fatal events will be logged but less severe warnings as
  26. well as fine-grained method entry and exit events can be obtained using
  27. the appropriate configuration. All regular compiler messages can also be
  28. logged through the infrastructure by setting the
  29. `org.aspectj.weaving.messages` System property.
  30. If you are running the AspectJ compiler/weaver under JDK 1.4 or earlier,
  31. AspectJ will use a simple built-in trace infrastructure that logs to
  32. stderr. This is enabled by setting the
  33. `org.aspectj.weaving.tracing.enabled` System property. You may also
  34. override the default behaviour or provide your own trace implementation
  35. using the `org.aspectj.weaving.tracing.factory` System property.
  36. The table below lists the System properties that can be used to
  37. configure tracing.
  38. [cols=",",options="header",]
  39. |===
  40. |Property |Description
  41. |`org.aspectj.tracing.debug` a|
  42. Enable simple debugging of the trace infrastructure itself.
  43. Default: `false`.
  44. |`org.aspectj.tracing.enabled` a|
  45. Enable the built-in AspectJ trace infrastructure.
  46. Default: `false`.
  47. |`org.aspectj.tracing.factory` |Select trace infrastructure. Specify the
  48. fully qualified class name of the
  49. `org.aspectj.weaver.tools.TraceFactory` interface to use a custom
  50. infrastructure. Specify a value of `default` to force AspectJ to use
  51. it's built-in infrastructure.
  52. |`org.aspectj.tracing.messages` a|
  53. Enable tracing of compiler messages. The kind of messages logged is
  54. determined by the selected trace infrastructure not the message
  55. configuration.
  56. Default: `false`.
  57. |===
  58. [[trace-examples]]
  59. === Examples
  60. Using `-Dorg.aspectj.tracing.factory=default` to force AspectJ to use
  61. its internal infrastructure, `-Dorg.aspectj.tracing.enabled=true` to
  62. turn it on and `-Dorg.aspectj.tracing.messages=true` to include messages
  63. running a simple HelloWorld with LTW will generate tracing to stderr.
  64. Below is an extract from that trace with method arguments removed. You
  65. will notice the millisecond time stamp, thread id and indication of
  66. entry/exit/event or message type for each line of trace.
  67. [source, text]
  68. ....
  69. 15:44:18.630 main > org.aspectj.weaver.loadtime.Aj.<init>
  70. 15:44:18.660 main < org.aspectj.weaver.loadtime.Aj.<init>
  71. 15:44:18.660 main > org.aspectj.weaver.loadtime.Aj.preProcess
  72. 15:44:18.660 main - org.aspectj.weaver.loadtime.Aj.preProcess
  73. 15:44:18.730 main > org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.<init>
  74. 15:44:18.730 main < org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.<init>
  75. 15:44:18.730 main > org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.initialize
  76. 15:44:18.821 main I [AppClassLoader@92e78c] info AspectJ Weaver Version DEVELOPMENT ...
  77. 15:44:18.821 main > org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.parseDefinitions
  78. 15:44:18.821 main I [AppClassLoader@92e78c] info register classloader ...
  79. 15:44:18.821 main - org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.parseDefinitions
  80. 15:44:18.841 main - org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.parseDefinitions
  81. 15:44:18.841 main I [AppClassLoader@92e78c] info using configuration ...
  82. 15:44:18.891 main < org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.parseDefinitions
  83. 15:44:19.021 main > org.aspectj.weaver.World$TypeMap.<init>
  84. 15:44:19.021 main < org.aspectj.weaver.World$TypeMap.<init>
  85. 15:44:19.021 main > org.aspectj.weaver.CrosscuttingMembersSet.<init>
  86. 15:44:19.021 main < org.aspectj.weaver.CrosscuttingMembersSet.<init>
  87. 15:44:19.021 main > org.aspectj.weaver.Lint.<init>
  88. 15:44:19.021 main < org.aspectj.weaver.Lint.<init>
  89. 15:44:19.021 main > org.aspectj.weaver.World.<init>
  90. 15:44:19.111 main < org.aspectj.weaver.World.<init>
  91. 15:44:19.201 main > org.aspectj.weaver.bcel.BcelWeaver.<init>
  92. 15:44:19.201 main < org.aspectj.weaver.bcel.BcelWeaver.<init>
  93. 15:44:19.201 main > org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.registerDefinitions
  94. 15:44:19.211 main > org.aspectj.weaver.bcel.BcelWeaver.setReweavableMode
  95. 15:44:19.351 main < org.aspectj.weaver.bcel.BcelWeaver.setReweavableMode
  96. 15:44:19.351 main > org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.registerAspects
  97. 15:44:19.351 main I [AppClassLoader@92e78c] info register aspect Aspect
  98. 15:44:19.351 main > org.aspectj.weaver.bcel.BcelWeaver.addLibraryAspect
  99. 15:44:19.501 main - org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass
  100. 15:44:19.632 main > org.aspectj.weaver.CrosscuttingMembersSet.addOrReplaceAspect
  101. 15:44:19.792 main < org.aspectj.weaver.CrosscuttingMembersSet.addOrReplaceAspect
  102. 15:44:19.792 main < org.aspectj.weaver.bcel.BcelWeaver.addLibraryAspect
  103. 15:44:19.792 main < org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.registerAspects
  104. 15:44:19.792 main < org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.registerDefinitions
  105. 15:44:19.792 main > org.aspectj.weaver.bcel.BcelWeaver.prepareForWeave
  106. 15:44:19.822 main < org.aspectj.weaver.bcel.BcelWeaver.prepareForWeave
  107. 15:44:19.822 main > org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.weaveAndDefineConcete...
  108. 15:44:19.822 main < org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.weaveAndDefineConcete...
  109. 15:44:19.822 main < org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.initialize
  110. 15:44:19.822 main > org.aspectj.weaver.tools.WeavingAdaptor.weaveClass
  111. ...
  112. ....
  113. Alternatively when running under Java 5 the `logging.properties` file
  114. below could be used to configure Java Logging. The resulting file, just
  115. containing trace for the `org.aspectj.weaver.loadtime` package, will be
  116. written to `java0.log` in your `user.home` directory.
  117. [source, text]
  118. ....
  119. handlers= java.util.logging.FileHandler
  120. .level= INFO
  121. java.util.logging.FileHandler.pattern = %h/java%u.log
  122. java.util.logging.FileHandler.count = 1
  123. java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
  124. java.util.logging.FileHandler.level = FINER
  125. org.aspectj.weaver.loadtime.level = FINER
  126. ....
  127. By setting the System property `-Dorg.aspectj.tracing.debug=true` you
  128. should see a message confirming which trace infrastructure is being
  129. used.
  130. [source, text]
  131. ....
  132. TraceFactory.instance=org.aspectj.weaver.tools.Jdk14TraceFactory@12dacd1
  133. ....