开发者

record the user interaction: log4j?

I need your suggestions. I have a Java application and i would like to record the way that the users use my application. I wonder what the most frequently used buttons are. Calculate the average length of introduction of a new patient in the application. Etc. In your opinion what is the best and simpler way to do that? Is it using Log4j?

Thank you for your collaboration.

Best regards.

Danie开发者_运维知识库l


Taking into account quite high-level requirements I will try to give high-level answer as well. For such kind of cross-cutting concerns which are quite separate from main business logic I'd suggest to use AOP (either AspectJ or Spring AOP if this is framework of your choice).

Building good set of dedicated aspects will take some time but it will definitely pay off as you'd be able to introduce this functionality gradually without much interfering with main application.

In this case I'd use some shared "statistics container" abstraction to collect information in aspects and then expose it over JMX or SNMP (or any other custom solution).


I don't especially see why log4j would be a bad choice. If you have a simple application, logging messages to file in a format that includes timestamps (and maybe thread identifiers depending on nature of your app) could be a straightforward way of recording the data you require. You would then need to invest a bit more in extracting the information you require from the log files.

Not saying anthing against AOP suggestion which would indeed be cleaner, but also more complex to get started with.


what can analyse your access log, you can see which url is accessed most -- so you can see which button is clicked most frequently -- if only this button lead to the url.


I have had in mind doing something similar for my application, and putting in at least some logging of high-level user events (open file, save, new, etc.) so that given only a log file it might be possible to tell what the user was doing.

Here is a good example to look at:
NetBeans Platform Gesture Collection Infrastructure.

This should give you some ideas of how to do what you want to do. If you have a Java Swing app, it can probably be ported to the NetBeans Platform and then you get this and more for free. Disclaimer: I am a satisfied developer on NetBeans Platform.

Although NetBeans is calling this 'Gesture Collection', it doesn't appear anyone else is, or that there is a generic term for this; "user action analytics" would be nice, but nearly anything with "analytics" now points to google. A lot of programs say "anonymous usage data" and that found me this similar question, which may help someone use Eclipse.

For a webapp, you should be able to gather much of this from the web access logs, possibly adding some additional info to the requests (e.g. '&userButton=SaveAs') or even adding some additional Ajax-y events to track the user (be careful to not generate too much additional traffic: only enable for some users; minimize server response with a zero-byte file like GET /zerobytes.txt?t=1313518123&event=hover&element=menuNav&duration=12). This should be pretty easier to do with jquery and likely no changes to your HTML.

On the server side, there is probably a richer set of tools to choose from and a number of technologies that support this (JMX, MBeans, JSR-77,etc). If you are talking about a webapp, JavaMelody with some application-specific custom events might be the way to go, especially if you could tie them to initiating some type of server-side processing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜