• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

where to write log info in the program.

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
David, Thanks.
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic