2

I wrote up a class to output logging information about my program. For instance, I initialize OpenGL and then write to the log. The old log example I have seen opens the file every single time it wants to output an error or success. Since I am writing an intensive graphics program, what would be the drawback of having the file open the entire time, writing to it and closing it when the program ends?

Is there a tradeoff?

Thanks!

  • 1
    See this question: [Should log file streams be opened/closed on each write or kept open during a desktop application's lifetime?](http://stackoverflow.com/questions/164053/should-log-file-streams-be-opened-closed-on-each-write-or-kept-open-during-a-des) – User May 09 '12 at 02:21

1 Answers1

-2

Why be concerned with writing to a logfile yourself? Just use a standard logging framework like the log4x series

Quagmire
  • 554
  • 6
  • 14
  • 1
    I am trying to understand every aspect that goes into the process. I don't want to use a huge logfile. My entire logfile class is only 25 lines. – Hobius Binks Jul 27 '11 at 08:28
  • Alright, perhaps you can go to the sites of log4net or log4j and just see if you can find out (in their forum) what strategy they use for writing to files. These are the most used packages, so whatever they are doing is probably the best way – Quagmire Jul 27 '11 at 09:03