wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes a bit of advice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "a bit of advice" Watch "a bit of advice" New topic
Author

a bit of advice

joew weakers
Ranch Hand

Joined: Aug 21, 2003
Posts: 48
Hey there. Not too sure if I should be posting this query here but it is so general that I wasn't sure where to post it. Basically what I want to do is to record every user interaction that a particular user has with a map representation in some sort of log file. My program renders maps to the screen and the user can switch features on and off and zoom in and out of various regions in the map. The program is set up to catch mouse events so that if the user clicks on, selects or drags on any part of the map, using the mouse, this can then be recorded. So simply is there any particular approach to recording these mouse events in logs or some other format that would best suit the requirements of my system. I am merely looking for advice on what is the best method to record user interaction wit hmy map system. Thanks a lot ... Joe
P.S. anybody who uses the system must be a valid user and therefore needs to log into the system. Therefore any interaction can be associated with one particular user.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
As of 1.4 Java has a Logger class that can write log entries. Actually it's a whole framework, very flexible and equally complex at times. There is some controversy about whether it was well designed, or maybe other loggers are better for big applications.
If you are into Do The Simplest Thing That Can Possibly Work, you might write your own Logger class with a static log(message) method and code it to write the message anywhere you want. I wrote my own (before 1.4 or Log4J) that publishes messages to any number of subscribers and the subscribers write to stdout, disk, an in-memory buffer, etc.
There are some attempts at standards around log entry formats, hoping to make log analyzers more interoperable. I think the 1.4 logger doc talks about them.
Hope that helps!


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Oh, and if you want to jump waaaaay into the deep end, look at Aspect Oriented Programming. It offers a way to add logging to code without touching the code. Sound magical? It is!
joew weakers
Ranch Hand

Joined: Aug 21, 2003
Posts: 48
Cheers Stan. Tahnks a lot for the advice. Sounds like a good call!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: a bit of advice