简体   繁体   English

在挂毯中记录事件调用

[英]Log event calls in tapestry

I want to log all event calls. 我想记录所有事件调用。 For example if a user clicks on an ActionLink I want to get the information that the event Action just occurred. 例如,如果用户单击ActionLink我想获取有关Action刚刚发生的信息。

In the documentation regarding logging it is stated that it's possible, but I don't quite understand how to do it. 在有关日志记录的文档中 ,它说是可能的,但我不太了解如何做到这一点。 It says: 它说:

Tapestry can also debug component event logic. Tapestry还可以调试组件事件逻辑。 The component's logger, with a "tapestry.events." 组件的记录器,带有“ tapestry.events”。 prefix, is used at debug level. 前缀,用于调试级别。 The debugging output identifies the event name and event source, and identifies any methods that are invoked. 调试输出标识事件名称和事件源,并标识调用的任何方法。

Note that events that are not handled by a component will bubble up to the component's container; 请注意,未由组件处理的事件将冒泡到该组件的容器中。 further logging for the same event will occur using the logger associated with the container. 使用与容器关联的记录器,将对同一事件进行进一步的记录。 The page containing the initial component is the final step when logging. 包含初始组件的页面是登录时的最后一步。

It's not really an instruction. 这不是真正的指示。 I tried something similar to this , but I couldn't find a way to enable an event logging property of the logger. 我想类似的东西这个 ,但我无法找到一个方法来使记录的事件日志记录属性。 Currently I only set my logger to debug level like this: 目前,我仅将记录器设置为调试级别,如下所示:

org.apache.log4j.Logger.getRootLogger().setLevel(Level.DEBUG);   
org.apache.log4j.Logger.getLogger("de.[...].Edit").setLevel(Level.DEBUG);

But this only seems to enable debugging level and events are still untracked. 但这似乎只能启用调试级别,并且事件仍未跟踪。

Also note that out of some reason I currently can't find my log4j.properties (log4j doesn't complain about it tho, so it probably does exist somewhere) file, so a solution without the requirement of this file would be nice. 还要注意,出于某种原因,我目前找不到我的log4j.properties (log4j对此并不抱怨,因此它可能确实存在于某处)文件,因此不需要此文件的解决方案将是不错的选择。 If that's not possible, it wouldn't be a problem either, I'd simply create a new properties file then or something like that. 如果这不可能,那么也就不会有问题,我只需要创建一个新的属性文件即可。

Actually I only had to properly read the documentation. 实际上,我只需要正确阅读文档即可。 The event logger is received like this: 像这样接收事件记录器:

org.apache.log4j.Logger eventLogger = org.apache.log4j.Logger.getLogger("tapestry.events.de.[...].Edit");

Which can then be set to debug similar to the normal logger: 然后可以将其设置为类似于普通记录器的调试方式:

eventLogger.setLevel(Level.DEBUG);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM