我试着用下一种方式配置加载时织入(用于使用Perf4J进行分析):
1)我添加aop.xml
到META-INF
文件夹.部署时,META-INF放置在工件根目录(即MyAppDeployed/META-INF
)中.
2)我把aspectjrt-1.6.1.jar
,aspectjweaver-1.6.1.jar
,commons-jexl-1.1.jar
,commons-logging.jar
到Tomcat/lib
文件夹(在第一次我尝试MyAppDeployed/WEB-INF/libs
,但它也没有工作).
3)我-javaagent:C:\apache-tomcat-6.0.33\lib\aspectjweaver-1.6.1.jar
在启动Tomcat时添加了VM选项.
4)我的aop.xml
:
<!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">
<aspectj>
<aspects>
<aspect name="org.perf4j.log4j.aop.TimingAspect"/>
</aspects>
<weaver options="-verbose -showWeaveInfo">
<include within="com.mypackages.MyClass"/>
</weaver>
</aspectj>
Run Code Online (Sandbox Code Playgroud)
我没有看到任何迹象表明装载时编织发生.无论是错误报告还是必要结果.我唯一的错误信息是:
Error occurred during initialization of VM
agent library failed to init: instrument
Error opening zip file: C:\apache-tomcat-6.0.33\lib\wrong-jar.jar
Run Code Online (Sandbox Code Playgroud)
在aspectjweaver-1.6.1.jar
指定javaagent参数时,我在名称中输入错误的情况.如果写得正确 - 不会打印错误信息.
任何想法,我做错了什么?
PS我使用Java 5,我尝试使用1.5.4
aspectj版本完全相同的结果.
我已经通过perf4J网站的以下链接,并做了同样的事情:http://perf4j.codehaus.org/devguide.html#Using_Spring_AOP_to_Integrate_Timing_Aspects
在我的spring.xml中添加了以下内容.
<aop:aspectj-autoproxy/>
<bean id="timingAspect" class="org.perf4j.log4j.aop.TimingAspect"/>
<bean id="wscClientBase" class="com.xyz.csa.core.common.WscClientBase"/>
Run Code Online (Sandbox Code Playgroud)
在类WscClientBase中,我使用@Profiled注释的以下方法.
@Profiled(tag = "SOAPCALLTEST")
public Object sendMessage(Object message) {
String msg = message.toString();
if (msg.indexOf(' ') > 1) {
msg = msg.substring(1, msg.indexOf(' '));
}
try {
Object ret = marshalSendAndReceive(message);
return ret;
} catch (RuntimeException ex) {
throw ex;
}
}
Run Code Online (Sandbox Code Playgroud)
我没有在应用程序日志中看到perf4j TimingLogger语句.但是,如果我使用它(如下没有注释),我会成功地看到日志语句.
public Object sendMessage(Object message) {
String msg = message.toString();
if (msg.indexOf(' ') > 1) {
msg = msg.substring(1, msg.indexOf(' '));
}
StopWatch stopWatch …
Run Code Online (Sandbox Code Playgroud) 我试图使用load-time-weaving将perf4j绑定到程序中,但它似乎没有在我的类路径中找到aop.xml.无论是那个还是它没有编织方面,因为它没有找到它.我已经从aop.xml启用了详细输出,但我没有看到任何编织消息,错误或其他.aspectJweaver在哪里查找META-INF/aop.xml?我怎么知道它在寻找哪一个?
我试图使用直接路径导入xml,但它没有用.-Dorg.aspectj.weaver.loadtime.configuration = C:\ dev的\主干\ BIN\META-INF\aop.xml文件
注意:程序按编程时编织工作,但我更喜欢使用load-time-weave.我还能够使用小型测试用例实现加载时编织.
我已经使用perf4j来计算过程的性能。现在,我要为该文件制作图形。是否可以不使用Google API或任何其他可用方法来实现?
大家好,我想知道在使用perf4j时logback.xml的确切配置设置.我在logback.xml中创建此配置
<configuration>
<!-- Perf4J appenders -->
<!--
This AsyncCoalescingStatisticsAppender groups StopWatch log messages
into GroupedTimingStatistics messages which it sends on the
file appender defined below
-->
<appender name="CoalescingStatistics" class="org.perf4j.logback.AsyncCoalescingStatisticsAppender">
<param name="TimeSlice" value="60000"/>
<appender-ref ref="graphExecutionTimes"/>
<appender-ref ref="graphExecutionTPS"/>
<!-- We add the JMX Appender reference onto the CoalescingStatistics -->
<appender-ref ref="perf4jJmxAppender"/>
</appender>
<appender name="graphExecutionTimes" class="org.perf4j.logback.GraphingStatisticsAppender">
<!-- Possible GraphTypes are Mean, Min, Max, StdDev, Count and TPS -->
<param name="GraphType" value="Mean"/>
<!-- The tags of the timed execution blocks to graph are specified …
Run Code Online (Sandbox Code Playgroud) perf4j ×6
java ×4
aspectj ×2
log4j ×2
performance ×2
aop ×1
jmx ×1
seam ×1
spring ×1
spring-aop ×1
testing ×1
tomcat ×1
unit-testing ×1