• Post Reply Bookmark Topic Watch Topic
  • New Topic

where to write log info in the program.  RSS feed

 
jing hu
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when writing code, I don't know whether or not to write logo info in some place.

For exmaple, should I write "enter f()" in function "f()"?
I don't know which detail degree should be the log info.

Can somebody tell me the the strategy of writting log info.
Some articles about writting log info will be better.

Thanks very much.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no rules for this-it just depends on what you want to log. Method entry is usually a debug/or trace level, though, sine you don't normally care-you just want to know that it did something right (or wrong). And the logging framework itself may log the method name-depends on what you're using and how it's configured. I don't put that kind of info into log statements, just useful info.

(I sometimes handle entry/exit via AOP, since I don't normally need that kind of detail, but it all depends.)
 
jing hu
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David, Thanks.
 
Sudipta Laha
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In generally its upto the user to decide what he wants to put in logs. Depending on critically of the errors log can be made at different level.
In my view, i place the exception in log level "ERROR" and user input(intermidiate calculation data) in log level 'DEBUG', so that its easy to debug when there are errors.

In general for a application log level "ERROR" is enabled, So we should try to write less details in it as it may impact the performance.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!