[英]Unitils @SpringApplicationContext - how to find time taken to initialize spring context?
I am using unitils for testing. 我正在使用unitils进行测试。 I see more than 90 spring context refresh messages in the failsafe test reports.
我在故障安全测试报告中看到了90多个spring上下文刷新消息。 I need to know how much time is taken to initialize these spring contexts.
我需要知道花了多少时间来初始化这些spring上下文。 Unitils does not have proper logging, so not able to track it with framework logs.
Unitils没有正确的日志记录,因此无法使用框架日志进行跟踪。
The @SpringApplicationContext
is on top of the test class, so cannot go for logger in my own test class @SpringApplicationContext
在测试类的顶部,因此无法在我自己的测试类中使用logger
Writing an advice or aware class or an interceptor will not help, as all these classes has to be registered in the spring xml and those beans which are registered in spring xml will be loaded only after the context is initialized 编写建议或感知类或拦截器将无济于事,因为所有这些类都必须在spring xml中注册,而那些在spring xml中注册的bean仅在上下文初始化后才加载
Writing an application listener class, we can catch only the ContextRefreshedEvent
, that is when the context in loaded not initialized. 编写应用程序侦听器类时,我们只能捕获
ContextRefreshedEvent
,即加载的上下文未初始化时。
Cannot catch the ContextStartedEvent
because it is published when the ApplicationContext is started using the start()
method on the ConfigurableApplicationContext interface
. 无法捕获
ContextStartedEvent
因为它是在ConfigurableApplicationContext interface
上使用start()
方法start()
ApplicationContext时发布的。 Whereas unitils dynamically creates new ClassPathXmlApplicationContext(..,..);
unitils动态创建新的
ClassPathXmlApplicationContext(..,..);
to create the spring context (class:org.unitils.spring.util.ClassPathXmlApplicationContextFactory)
创建spring上下文
(class:org.unitils.spring.util.ClassPathXmlApplicationContextFactory)
How do I calculate spring context initialization time? 如何计算Spring上下文初始化时间?
What about simple log4j logger? 那么简单的log4j记录器呢? When logging Spring info logs you can see ContexLoader initialization time.
在记录Spring信息日志时,您可以看到ContexLoader初始化时间。
17:25:48 INFO - ContextLoader - Root WebApplicationContext: initialization started 17:25:48信息-ContextLoader-根WebApplicationContext:开始初始化
17:25:53 INFO - ContextLoader - Root WebApplicationContext: initialization completed in 5325 ms 17:25:53信息-ContextLoader-根WebApplicationContext:初始化在5325毫秒内完成
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.