blob: d5073a12c1c3030e5db1b14a9eb7f9950dcdb731 [file] [log] [blame]
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Chapter 4. Tracing</title><link rel="stylesheet" href="aspectj-docs.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.44"><link rel="home" href="index.html" title="The AspectJtm Problem Diagnosis Guide"><link rel="up" href="index.html" title="The AspectJtm Problem Diagnosis Guide"><link rel="previous" href="ajcore.html" title="Chapter 3. AspectJ Core Files"><link rel="next" href="ltwdump.html" title="Chapter 5. Dumping classes during load-time weaving"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 4. Tracing</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ajcore.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="ltwdump.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><h2 class="title"><a name="trace"></a>Chapter 4. Tracing</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="trace.html#trace-introduction">Introduction</a></dt><dd><dl><dt><a href="trace.html#trace-configuration">Configuring Tracing</a></dt><dt><a href="trace.html#trace-examples">Examples</a></dt></dl></dd></dl></div><div class="sect1"><a name="trace-introduction"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="trace-introduction"></a>Introduction</h2></div></div><p>
The AspectJ developers have instrumented the compiler/weaver with
many "trace" messages for their own debugging use. These remain in
the production releases because tracing helps when it is hard to
isolate the problem in a test case. This sections describes how
to enable tracing so you can provide trace information on bug reports.
</p><p>
The usual approach to opening a report on Bugzilla is to describe the symptoms of the
problem and attach a simple testcase. This allows the AspectJ team to try and reproduce the problem in
an attempt to fix it as well as improve the test suite. Unfortunately it may not be possible
to produce such a testcase either because your program is too large or is commercially sensitive. Alternatively
the problem may relate to your specific environment where AspectJ is being used and will not be
reproducible by the AspectJ team. In each of these situations you can produce a
trace of the compiler when the problem occurs instead. This can then be attached to the bug report. </p><div class="sect2"><a name="trace-configuration"></a><div class="titlepage"><div><h3 class="title"><a name="trace-configuration"></a>Configuring Tracing</h3></div></div><p> When available (Java 5 or later) AspectJ will use the
<a href="http://java.sun.com/j2se/1.5.0/docs/guide/logging/index.html" target="_top">
java.util.logging</a> infrastructure
configured using a <tt>logging.properties</tt> file. By default only error
and fatal events will be logged but less severe warnings as well as fine-grained
method entry and exit events can be obtained using the appropriate configuration. All
regular compiler messages can also be logged through the infrastructure by setting the
<tt>org.aspectj.weaving.messages</tt> System property. </p><p> If you are running the AspectJ compiler/weaver under JDK 1.4 or earlier,
AspectJ will use a simple built-in trace
infrastructure that logs to stderr. This is enabled by setting the
<tt>org.aspectj.weaving.tracing.enabled</tt> System property. You may also override
the default behaviour or provide your own trace implementation using the
<tt>org.aspectj.weaving.tracing.factory</tt> System property. </p><p> The table below lists the System properties that can be used to configure tracing. </p><div class="informaltable" id="d0e541"><a name="d0e541"></a><table border="1"><colgroup><col><col></colgroup><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><tt>org.aspectj.tracing.debug</tt></td><td>
Enable simple debugging of the trace infrastructure itself.
<p> Default: <tt>false</tt>. </p></td></tr><tr><td><tt>org.aspectj.tracing.enabled</tt></td><td>
Enable the built-in AspectJ trace infrastructure.
<p> Default: <tt>false</tt>. </p></td></tr><tr><td><tt>org.aspectj.tracing.factory</tt></td><td>
Select trace infrastructure. Specify the fully qualified class name
of the <tt>org.aspectj.weaver.tools.TraceFactory</tt>
interface to use a custom infrastructure. Specify a value of
<tt>default</tt> to force AspectJ to use it's
built-in infrastructure.
</td></tr><tr><td><tt>org.aspectj.tracing.messages</tt></td><td>
Enable tracing of compiler messages. The kind of messages logged
is determined by the selected trace infrastructure not the message
configuration.
<p> Default: <tt>false</tt>. </p></td></tr></tbody></table></div></div><div class="sect2"><a name="trace-examples"></a><div class="titlepage"><div><h3 class="title"><a name="trace-examples"></a>Examples</h3></div></div><p> Using <tt>-Dorg.aspectj.tracing.factory=default</tt>
to force AspectJ to use its internal infrastructure,
<tt>-Dorg.aspectj.tracing.enabled=true</tt> to turn it on and
<tt>-Dorg.aspectj.tracing.messages=true</tt> to include messages
running a simple HelloWorld with LTW will generate tracing to stderr. Below
is an extract from that trace with method arguments removed.
You will notice the millisecond time stamp,
thread id and indication of entry/exit/event or message type for each line
of trace.
</p><pre class="programlisting">
15:44:18.630 main &gt; org.aspectj.weaver.loadtime.Aj.&lt;init&gt;
15:44:18.660 main &lt; org.aspectj.weaver.loadtime.Aj.&lt;init&gt;
15:44:18.660 main &gt; org.aspectj.weaver.loadtime.Aj.preProcess
15:44:18.660 main - org.aspectj.weaver.loadtime.Aj.preProcess
15:44:18.730 main &gt; org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.&lt;init&gt;
15:44:18.730 main &lt; org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.&lt;init&gt;
15:44:18.730 main &gt; org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.initialize
15:44:18.821 main I [AppClassLoader@92e78c] info AspectJ Weaver Version DEVELOPMENT ...
15:44:18.821 main &gt; org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.parseDefinitions
15:44:18.821 main I [AppClassLoader@92e78c] info register classloader ...
15:44:18.821 main - org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.parseDefinitions
15:44:18.841 main - org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.parseDefinitions
15:44:18.841 main I [AppClassLoader@92e78c] info using configuration ...
15:44:18.891 main &lt; org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.parseDefinitions
15:44:19.021 main &gt; org.aspectj.weaver.World$TypeMap.&lt;init&gt;
15:44:19.021 main &lt; org.aspectj.weaver.World$TypeMap.&lt;init&gt;
15:44:19.021 main &gt; org.aspectj.weaver.CrosscuttingMembersSet.&lt;init&gt;
15:44:19.021 main &lt; org.aspectj.weaver.CrosscuttingMembersSet.&lt;init&gt;
15:44:19.021 main &gt; org.aspectj.weaver.Lint.&lt;init&gt;
15:44:19.021 main &lt; org.aspectj.weaver.Lint.&lt;init&gt;
15:44:19.021 main &gt; org.aspectj.weaver.World.&lt;init&gt;
15:44:19.111 main &lt; org.aspectj.weaver.World.&lt;init&gt;
15:44:19.201 main &gt; org.aspectj.weaver.bcel.BcelWeaver.&lt;init&gt;
15:44:19.201 main &lt; org.aspectj.weaver.bcel.BcelWeaver.&lt;init&gt;
15:44:19.201 main &gt; org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.registerDefinitions
15:44:19.211 main &gt; org.aspectj.weaver.bcel.BcelWeaver.setReweavableMode
15:44:19.351 main &lt; org.aspectj.weaver.bcel.BcelWeaver.setReweavableMode
15:44:19.351 main &gt; org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.registerAspects
15:44:19.351 main I [AppClassLoader@92e78c] info register aspect Aspect
15:44:19.351 main &gt; org.aspectj.weaver.bcel.BcelWeaver.addLibraryAspect
15:44:19.501 main - org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass
15:44:19.632 main &gt; org.aspectj.weaver.CrosscuttingMembersSet.addOrReplaceAspect
15:44:19.792 main &lt; org.aspectj.weaver.CrosscuttingMembersSet.addOrReplaceAspect
15:44:19.792 main &lt; org.aspectj.weaver.bcel.BcelWeaver.addLibraryAspect
15:44:19.792 main &lt; org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.registerAspects
15:44:19.792 main &lt; org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.registerDefinitions
15:44:19.792 main &gt; org.aspectj.weaver.bcel.BcelWeaver.prepareForWeave
15:44:19.822 main &lt; org.aspectj.weaver.bcel.BcelWeaver.prepareForWeave
15:44:19.822 main &gt; org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.weaveAndDefineConcete...
15:44:19.822 main &lt; org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.weaveAndDefineConcete...
15:44:19.822 main &lt; org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.initialize
15:44:19.822 main &gt; org.aspectj.weaver.tools.WeavingAdaptor.weaveClass
...
</pre><p> Alternatively when running under Java 5 the <tt>logging.properties</tt>
file below could be used to configure Java Logging. The resulting
file, just containing trace for the
<tt>org.aspectj.weaver.loadtime</tt> package, will be
written to <tt>java0.log</tt> in your <tt>user.home</tt> directory.
</p><pre class="programlisting">
handlers= java.util.logging.FileHandler
.level= INFO
java.util.logging.FileHandler.pattern = %h/java%u.log
java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.FileHandler.level = FINER
org.aspectj.weaver.loadtime.level = FINER
</pre><p>
By setting the System property <tt>-Dorg.aspectj.tracing.debug=true</tt>
you should see a message confirming which trace infrastructure is being used.
</p><pre class="programlisting">
TraceFactory.instance=org.aspectj.weaver.tools.Jdk14TraceFactory@12dacd1
</pre></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ajcore.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="ltwdump.html">Next</a></td></tr><tr><td width="40%" align="left">Chapter 3. AspectJ Core Files&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right">&nbsp;Chapter 5. Dumping classes during load-time weaving</td></tr></table></div></body></html>