• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: concerning logging

 
Ulrich Heeger
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
I have two general questions concerning logging.
Until now I haven't implemented logging, so I'm not used to it.
1. If I want to deliver my assignment with logging, is it recommandable to output the logging in a file or is it enough to log it with the console?
2. Should I avoid to log within private methods?
Thanks in advance
Ulrich
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11866
194
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulrich,

1. If I want to deliver my assignment with logging, is it recommandable to output the logging in a file or is it enough to log it with the console?

Personally at submission time I would set the default logging level to a point where nothing gets logged, and output that nothing to the console. I would also have options within the application that allow logging to be saved to file and set the log level to a useful value. My reasoning:
  • Logging to file:
    What file are you going to put these log messages in, and where is it going to be stored?
    If you go with a default filename (e.g. "assignment.log") and store it in the current working directory, then you may have a problem if two people start their application in the same working directory - one will overwrite the other.
    Do you append a date / time stamp and/or something else to ensure that each log has a unique filename? If so, how do you handle the fact that in a years time you will have 365 log files out there?
    Or if you have one single file per user, how big do you allow it to grow?
    And anyone trying to clean up when they delete your application will not be very impressed with log files scattered around the place.
    (These are all things you would have to consider in a real life application, and they can all be handled fairly easily, but they are overkill for this assignment - save yourself the bother and put default logging to console for this assignment).
  • Logging to console:
    Having things appear on the console without expecting them can be disconcerting. It may only take a moment to realise that these are log messages and not errors, but for the first few seconds people may panic about the state of the application.
    Plus if you do want to put errors on the console they may be lost in amongst the log messages.
    And if the application is being run as a server process, the standard output may be redirected to a system log file, which can result in you filling up the system log - a sure way to get the system administrators upset with you.


  • So I would probably just set standard logging to console, set the logging level high enough that nothing gets logged, then have a menu option which will bring up a dialog where the user can choose where to store their log file and what level to log.
    2. Should I avoid to log within private methods?

    You should log anywhere that you might want to see what has been happening. So if you want to see what was happening in a private method then put logging in there.
    Regards, Andrew
     
    Ulrich Heeger
    Ranch Hand
    Posts: 266
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Andrew,
    thanks a lot for your help.
    You should log anywhere that you might want to see what has been happening. So if you want to see what was happening in a private method then put logging in there.


    (These are all things you would have to consider in a real life application, and they can all be handled fairly easily, but they are overkill for this assignment - save yourself the bother and put default logging to console for this assignment).

    So I would probably just set standard logging to console, set the logging level high enough that nothing gets logged, then have a menu option which will bring up a dialog where the user can choose where to store their log file and what level to log.

    Concerning the menu option I have some questions.
    1. Where would you suggest to show this menu option? Within my Server-GUI for the server and within the starting Client-GUI (the GUI which store the property specifications) for the Client? Would you store these logging properties in the suncertify.properties, thus the next time the application starts, the logging will be executed confirming these properties?
    2. Concerning the storing of the log file, would you suggest to use a FileChooser like:

    Thanks in advance and greetings to down under
    Ulrich
     
    Max Habibi
    town drunk
    ( and author)
    Sheriff
    Posts: 4118
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Ulrich,
    You can do a search to get my long-winded response to this: but in general, I suggest
    a. Log only to the console
    b. Log generously
    All best,
    M
     
    Ulrich Heeger
    Ranch Hand
    Posts: 266
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Max,
    thank you for your answer.
    After have read some threads concerning logging I'm asking myself if I should generally omit logging of my assignment before submission.
    I have to think about that, I would be very glad if you could just give me an advice concerning following points.
    1. If I omit logging generally but keep it for logging exception messages, do you think I violate the consistence for logging?
    2. How would you recommend to log or print exception messages to the console, like for example in the GUIController-Class:

    or

    The second snippet produces this ugly output at the console but is more informative.
    Which version would you prefer?
    Thanks a lot in advance & Regards
    Ulrich
     
    Max Habibi
    town drunk
    ( and author)
    Sheriff
    Posts: 4118
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    For exceptions, go with the ugly output.
    M
     
    Ulrich Heeger
    Ranch Hand
    Posts: 266
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Max,
    thank you.
    Ulrich
     
    Max Habibi
    town drunk
    ( and author)
    Sheriff
    Posts: 4118
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Ulrich Heeger:
    Hi Max,
    thank you.
    Ulrich

    Np, but you knew the answer to that one without having to ask me.
    M
     
    Ulrich Heeger
    Ranch Hand
    Posts: 266
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Max,
    Np, but you knew the answer to that one without having to ask me.

    You're right.
    I'm getting slowly paranoid having worked so long for this exam, I begin to distrust my own reason
    Ulrich
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic