Slashdot Mirror


Software Logging Schemes?

MySkippy writes "I've been a software engineer for just over 10 years, and I've seen a lot of different styles of logging in the applications I've worked on. Some were extremely verbose — about 1 logging line for every 2 lines of code. Others were very lacking, with maybe 1 line in 200 devoted to logging. I personally find that writing debug and informational messages about every 2 to 5 lines works well for debugging an issue, but can become cumbersome when reading through a log for analysis. I like to write warning messages when thresholds or limits are being approached — these tend to be infrequent. I log errors whenever I catch one (but I've never put a 'fatal' message in my code, because if it's truly a fatal error I probably didn't catch it). Recently I came across log4j and log4net and have begun using them both. That brings me to my question: how do the coders on Slashdot handle logging in their code?"

57 of 225 comments (clear)

  1. What do you want to achieve... by AaronLawrence · · Score: 5, Informative

    As usual, "it depends" on what you are trying to achieve. Nobody can give you a blanket recommendation. But I guess in general: the log files need to give you enough information, that can't be got in other ways, to solve any problem that comes up.

    We have a realtime product that goes all over the world and talks to hardware that we can't always get access to ourselves. Therefore, we sometimes must debug our code remotely. Obviously, logging is critical to this. We keep sometimes hundreds of MB of logs and have archiving rules and a tool for users to collect them. Every layer of the system keeps it's own logs, and all logs have timestamps to milliseconds.

    In our case we log all the data back and forth, and then every important decision the code makes. For example if it decides there is something wrong with incoming data, it must log that. Any action it decides to take must be logged. Any data that will be passed on to other layers/the outside world must be shown. Generally, whenever we forget to log some of this data we will later regret it ("why the hell is it ignoring that device state..."). We also log at startup, basically the whole system configuration so that we can reproduce it.

    Callstacks when there is an exception can be very useful. However, a lot of "errors" (at least in our case) are not exceptions but rather unexpected data or behaviour. We rarely have a crash and in state-based systems a callstack doesn't tell you much about what's going on. So a callstack is not useful for all situations.

    Other times, you just want logging to give you a clue where in the code it was so you can run up the debugger and step through it (you do know how to step through code in the debugger, right?). In that case, too much logging can just get in the way. It might be sufficient in a GUI or web app to say which screen/page and which button was clicked.

    You'd hope users could report this kind of details, but not always: if the user is working in another language, in another country, with two layers of helpdesk between you and them, and they are busy doing other things when the problem occurs and only call in the issue an hour later, and the helpdesk takes a week to report it to you - you may just get a vague or even misleading report that no-one can remember when you ask questions. In those cases log files may be all you have to go on.

    There is also a tradeoff between log detail and manageability. Besides the difficulty in reading long log files, having a lot of detail means maintaining a lot of extra code. It also means that log files can become unmanagably large. In our case those hundreds of MB of logs can be a huge problem for customers to send to us because they have low quality internet connections (small companies in Mexico for example).

    --
    For every expert, there is an equal and opposite expert. - Arthur C. Clarke
    1. Re:What do you want to achieve... by ericfitz · · Score: 5, Informative

      +1 for parent.

      If you want good logging, then define requirements for it, just as you would for any other feature of the program. You also need to define the audience for the log. The comments thread has focused on debug logging for developers (Linus "no debuggers" Torvalds would be proud) but there are a number of reasons why the users who are stuck^h^h^h blessed with your software might want logging. For instance:

      - audit trails (often required by organizational security requirements or regulatory requirements)
      - accounting/billing (you'd be amazed at the odd ways people come up with to bill for things)
      - health monitoring (the admin might not want to watch your program 24x7 to see if it is running; they might want to program automation to be alerted when it is not working properly)
      - troubleshooting (believe it or not, your software might actually break when running in the wild)

      Anyway, think about your use cases, and then think about what to instrument for each use case, and what to put in the events.

      For instance, if you want to make your daemon monitorable for health, then think about all its dependencies. Does it read config from a file? The file is a dependency. What happens if a value is invalid? Does it fail or use a default? If it fails, reading the value is a dependency. Need a network socket? Dependency. Connection to remote machine? Dependency (actually multiple- name resolution, network connectivity, authentication, app-level connectivity, etc.). After you've enumerated all your dependencies, then add instrumentation in your code to log events when the dependency is unsatisfied (==unhealthy/broken), and when it is satisfied (==healthy). Make sure to log BOTH states, so that the monitoring app can decide which state you are in. Make sure to log only once per state transition. In each event, try to put as much information about the situation as you can- why you are in the state ("the value foo from daemon-config was invalid"), status codes, etc.- give your user a fighting chance of being able to use your log to diagnose and resolve the issue.

      If you want to instrument for audit, then I suggest reading the Orange Book or the Common Criteria documents for suggestions on what needs to be audited and what information to put in the events.

      For accounting, examine the RADIUS RFCs.

      Hope this helps.

  2. Three levels by spaceyhackerlady · · Score: 2, Interesting

    I find I usually end up with 3 levels of logging:

    Normal operation, often with some notion of "Yes, I'm still running even though I haven't done anything else lately".

    Details. Usually corresponding to processing steps.

    Algorithm tracing. This includes things like logging SQL queries. This is usually only of interest to me.

    ...laura

  3. Standard format for domain information by MichaelSmith · · Score: 4, Informative

    I work on a large air traffic control system. Logging is a huge issue. Log files are collected centrally by a separate application. One important issue IMO is making the contents of your various log files meaningful to people who are not familiar with them.

    If your system has objects of type A B and C which can be handled by different components of your system then your should make the logging system in those components print information about those objects in exactly the same way.

    While you are at it, make the log format easily parsable by software. You don't want to be looking for a needle in a gigabyte size haystack of trace information without help from a tool which understands what it is looking for.

    1. Re:Standard format for domain information by MichaelSmith · · Score: 2, Funny

      Enjoy all the fun of ADS-B =) As an IT professional and a private pilot, I hope if you're working on a project related to that, it works flawlessly.

      Cripes if it is working flawlessly we had better stop changing stuff ;)

  4. It varies by pjwhite · · Score: 2, Interesting

    I will add lots of logging to debug a specific problem and then rip it out when the problem is fixed. Permanent logging includes run time problems like serial communication errors, file not found, etc. I like to make various logging functions switchable, so user input can be logged for example, but only when needed. Once a program is running well, it should only log data for dire exceptions, unless regular accounting logs are needed.

  5. Re:As little as practically possible by 0123456 · · Score: 5, Insightful

    "Otherwise don't do much logging because it will hurt application performance, sometimes drastically."

    You're assuming that performance -- or, more precisely, CPU usage -- is important; in many cases, reliability (and being able to track down bugs after a crash) are far more important than CPU usage. With quad-core CPUs so cheap these days, we can easily afford to spend another thousand dollars to throw more processing power into a system which has cost a couple of hundred thousand dollars of programmer time to develop and will cost thousands of dollars an hour for any downtime.

  6. Logging to a database by Animats · · Score: 3, Informative

    My online applications log to a database, not a text file. Multiple applications on different machines can log to the same database table. There's no need for "log rotation"; old entries can be summarized and purged by date on the live database. With appropriate indexed fields, you can find key log entries in huge log files very rapidly.

    Even program faults are logged to the database. If the program crashes, the top-level exception handler catches the event, does a traceback, opens a fresh database connection, and logs the traceback.

    1. Re:Logging to a database by plierhead · · Score: 2, Interesting

      IMO database logging has good points and bad points: On the good side, its easy to manipulate (query, purge, transform, summarise) the log entries. Also you can access the log entries remotely using the database tools you already know. On the bad side, its undoubtedly slower and more resource-intensive. Also, unless you have multiple DB connections (which itself raises complexity and overhead), then committing a log entry to the database will also commit your unit of work. It seems to work well for "user logging", i.e. where the end user of your application (rather than just the dev team) would want to read the messages.

      --

      [x] auto-moderate all posts by this user as insightful

    2. Re:Logging to a database by AaronLawrence · · Score: 3, Insightful

      Not to mention the added complexity and failure modes. All but the most trivial databases can go wrong in interesting ways, and when that happens where will you put your logging? It's precisely when things go wrong that you need logging the most. So you want the least possible dependencies. Right now, that's appending text to a file - file systems are simpler and tested more thoroughly than even the best databases can be.

      Like the user (or the system, or the virus...) shutdown the database server in the middle of operation. How do you prove that after the fact if the logs were going into the database?

      --
      For every expert, there is an equal and opposite expert. - Arthur C. Clarke
  7. taking it a big further - no logging at all by JonTurner · · Score: 3, Insightful

    Don't coddle weak programmers... it's survival of the fittest out here. Either they learn to nourish themselves from the ample teat of a stack dump, or they must perish. It is for the good of our civilization. I know this seems harsh, young Jedi, but it is the way of the Elders of Assembler, from the ancient Time Before OO. Now go Forth and code.

    Okay, joking aside. Parent has a great point -- logging can generate incredible volumes of text and can form a remarkable bottleneck, especially on VM systems where your OS may not be the only one hitting the disk.
    So take advantage of Log4J/Net's ability to log at different severity levels and make logging globally configurable so you can enable/disable entirely at runtime. I'd recommend you log the following : object creation, scarce resource allocation, recoverable failure/error conditions and unrecoverable failures. Preface each severity level with a unique label so you can grep for it later. Even at the most verbose level, you can then grep your output to see only what's of interest to you (e.g. "unrecoverable:...").

    1. Re:taking it a big further - no logging at all by BobGregg · · Score: 4, Interesting

      I just had occasion to try and optimize an old C++ app that was having performance issues in certain sections. This app had its own custom logging system using Unix message queues, and was always a little suspect. I noticed as I tried to instrument the code that whenever I seemed to get close to the bottleneck, the problem seemed to move to a different part of the code. Finally, it dawned on me that the log system itself was part of the problem. In fact, the log object constructor was taking significant time, including (in some places) within critical (as in lock/unlock) sections. Most critical classes had been defined with an instance of the logger as a member, which was overkill. Doing nothing more than changing the definitions of the log objects to static dropped critical section performance by an entire order of magnitude.

      Moral: Do logging, but do it judiciously. Know what you're doing - and know what the log system is doing too.

  8. whatever you do, don't use nfs by Sir_Real · · Score: 4, Interesting

    If you're using log4j, don't use multiple hosts to write to the same nfs filesystem file. You'll run into blocking issues and log4j doesn't handle them correctly. The nirvana of clustered app logging is an async JMS queue. You fire off the message and forget it. You don't wait for file handles.

  9. not cpu bound... disk bound by JonTurner · · Score: 5, Insightful

    It's not CPU that's at a premium, it's disk IO. And on virtualized machines (such as is extremely popular in corporations and hosting farms) where there might be four different OSs running on the same physical hardware, disk becomes a scarce resource very, very quickly. And not only does your virtualized server go to shit, it takes the others down with it since they can't get timely disk access, either.

    1. Re:not cpu bound... disk bound by Heembo · · Score: 4, Informative

      For high availability clustered web applications, it's not disc IO that is the problem, but network overhead.

      I tend to use log4j and asynchronous logging that passes log messages to a syslog server that can handle the file io - and it ends up being network overhead that is the killer.

      --
      Horns are really just a broken halo.
    2. Re:not cpu bound... disk bound by hackstraw · · Score: 3, Insightful

      I tend to use log4j and asynchronous logging that passes log messages to a syslog server that can handle the file io - and it ends up being network overhead that is the killer.

      People have said disk io, CPUs, and they say they are both cheap. NICs are VERY cheap.

    3. Re:not cpu bound... disk bound by morgan_greywolf · · Score: 2, Interesting

      Companies with virtualized machines are often also using storage area networking and related high-availability technologies. The traditional bottleneck associated with disk I/O does not happen nearly as badly.

    4. Re:not cpu bound... disk bound by gallwapa · · Score: 3, Informative

      ehhh. HP 373i quad port gig nic pci express kicks ass and only runs about $350

    5. Re:not cpu bound... disk bound by ralfe · · Score: 2, Interesting

      One solution I have found for this is to write my own logging application. I write mainly web-based software and AGI stuff, and all my software makes use of the same logging application. Basically what happens is that when I want to write to the log (which is stored in a MySQL database so analysis and viewing the logs is enhanced), the software simply tells the OS to execute the logging utility which can be niced or deprioritised on the system. This way, the software doesn't have to worry about I/O to the log, it doesn't have to wait for MySQL and it can carry on without the hassles involved in rewritting bits of logging code for each project. I have found this works really well for me, and having all the logs for all my code in a central database makes it easy for me to write some nice little AJAX/PHP app to apply filters to the logs or to analyse the logs, whatever I want basically. However, I know this method is not practical for many situations.

  10. Depends on the application you're writing by lteo_calyptix · · Score: 2, Interesting

    It depends on the app you're writing -- is it a web app, a database app, a userspace program written in C, a Perl/Ruby script, or.. At work we created our own logging library in C to emit log events for different levels, e.g. informational, debugging, warnings, errors, fatal messages. We then have wrappers around that library so that languages like Ruby can access that logging library. But on hindsight I think I would've just used syslog if I had to start over. :)

  11. I Don't! by Vectronic · · Score: 4, Funny

    I don't, save the rain forest, hug a tree, prevent deforestation, stop logging now!

    1. Re:I Don't! by robfoo · · Score: 2

      *whoosh*

    2. Re:I Don't! by Shados · · Score: 2

      Oh...hrm...yeah, I feel dumb.

  12. I let the kernel do it for me by ILongForDarkness · · Score: 2, Funny

    Segmentation fault: core dumped

  13. Logging, parts I and II by trapezoid · · Score: 2, Informative

    I wrote up a two-part piece on logging best and worst practices a while back. See Part I and Part II if you are interested.

  14. TOO MUCH! by imp · · Score: 2, Interesting

    1 line of logging per 200 lines of code is way too much. 2 in 5 lines is absolutely insane. I've seen way too many systems where the logging made it totally unusable. People just don't realize the costs of logging everything.

    There's absolutely no way to document anything this verbose. Without documentation, the logging is useless.

  15. Re:youre doing it wrong by wdsci · · Score: 2, Interesting

    Agreed, logging every 2 to 5 lines gives you the kind of information that you should really be getting with a debugger. Of course, when you're trying to diagnose a specific problem, sometimes it can be easier to put log messages every line or two than to repeatedly step through the code with a debugger, but that's sort of the same thing, just a temporary debugging aid - most of that logging output should be removed once you've figured out what's going on. For general use, I think about one log call per function might be reasonable - more if it's a long function, or none if it's a short function that does something really simple. And even most of those should probably be disabled once you release the software.

  16. Comment removed by account_deleted · · Score: 2, Interesting

    Comment removed based on user account deletion

  17. Filters by zarthrag · · Score: 2, Interesting

    My logging is setup so I can quickly filter down to the type of data I want. It's more than just "information", "warning", and "error" - but by (cpp)file, module, etc. That way, if an issue arises, I can eliminate the cruft and see just what I need. Just takes planning.

    --
    Why can't all fpga/microcontroller manufacturers just release free optimizing compilers???
  18. Re:As little as practically possible by dslauson · · Score: 4, Insightful

    "You're assuming that performance -- or, more precisely, CPU usage -- is important; in many cases, reliability (and being able to track down bugs after a crash) are far more important than CPU usage."

    I work on a real-time embedded medical device, where both performance and reliability are vital. We've got constrained resources, and the system must be extremely responsive.

    Our logging scheme is pretty cool. It's written so that two computers can log to a single hard drive, and each logging statement must define a log level. So, for example, if I'm writing GUI code, I can log to log_level_gui_info, log_level_gui_debug, log_level_gui_error, or any of a number of more specific log levels.

    The idea is

    1. Some of these log levels we can turn off before a production release.
    2. We have a special tool for reading these logs (they're encrypted), and in this tool you can check off which log levels you care to see, and which you don't

    So, we have two ways to filter out extraneous logging that we don't care about (one actually keeps the logging from happening, and one just filters it out during analysis), and we can log as freely as we like as long as we're smart about which levels we're using.

    As much faith as we all have in our own code, nothing's as frustrating as trying to analyze a log that came in from the field where there's just no information about what went wrong.

  19. Whatever is useful while programming. by Restil · · Score: 2, Informative

    I tend to do my debugging by inserting a lot of printf statements to indicate where in the program I currently am and the value of any critical variables at that time. As the output information is no longer needed (i.e. I fixed the bug it was attached to), I tend to cull out whatever isn't useful anymore. However, I tend to keep starting messages in function calls related to a routine I'm working on or making more than a trivial change to... since chances are, knowing me, I'm going to end up putting them back in there anyway once I create a new bug... and lets face it, it WILL happen.

    Once I'm done, I go back, remove or comment out (usually just comment out) all the messages that have no redeeming value for a properly functioning program, and turn the rest into debug statements which print based on the debug level provided at execution time... or sometimes I use a mask to select which types of messages to display.

    -Restil

    --
    Play with my webcams and lights here
    1. Re:Whatever is useful while programming. by CastrTroy · · Score: 2, Insightful

      Disappointingly enough, this is one of the things that isn't covered very well in a lot of courses. I didn't get any exposure to debuggers in any classes I took throughout university. I learned about it myself. Same goes for a lot of other useful tools like source control systems. While I learned a lot while taking my degree, very little of what I learned dealt directly with the process of how you actually sit down and write code. Seriously, some people think that printf really is the best/only way to debug, and I can see why. My first Java course had us all typing up code in notepad and compiling/running from the command line. After that, courses just told us to use Java, without pointing to any specific tools that we should be using. It was so bad, that first year Java actually used a special add on library to do input output using a GUI, so when it came time do not use that in second year, we had to go figure out how to do IO all over again.

      --

      Anthropic principle: We see the universe the way it is because if it were different we would not be here to see it.
  20. Lotsa logging by SpinyNorman · · Score: 3, Informative

    I write code for Telecom test systems that need to run 24x7 processing highly varying requests from dozens of different client systems. Our system consists of dozens of different processes/components per host, with multiple hosts all invoking components on each other as needed (all via CORBA). There are very many paths that any request can take through our system.

    In this environment we log VERY heavily since each request is close to unique and we need to be able to determine the path it took through the system, and why it did, and what happened, in the event of any bug report. Some of the haviest used modules can produce close to 1GB of log per day per host - upto a couple hundred lines of logging information per request per process that it passes thru. We use a custom printf-like log library written in C++ (that auto rotates the log files based on various criteria), a custom tail utility for dealing with the large log files (tail a log file from a given timestamp - done instantly via binary search on the timestamps) and a daily cron job to compress the older log files and move any older than 5 days off the production servers to someplace with more storage.

  21. One line of logging for every line of comments by sprior · · Score: 3, Funny

    That should be about right...

  22. As much as practically possible by Anonymous Coward · · Score: 5, Insightful

    On the other hand, broken code hurts application performance, sometimes drastically.

    I'm an SQA engineer with years of experience working with large scale enterprise systems. Generally speaking the cost of unexpected outages or data corruption outweighs the cost of hardware. In such systems the costs of deployment activity itself can be such that you'd rather pay for more hardware to support extremely verbose logging.

    Sure, boneheaded logging can cause unnecessary performance hits, the obvious example being logging in a loop when logging at entry and exit would have sufficed. But that's not what we are really talking about here. You posited that you should do as little logging as practically possible, and I believe that you are wrong.

    Log lots and log often. Just do so intelligently. Use a logging framework (log4j, log4net, log4perl etc) and set the priority appropriately. Only use ERROR for real errors (unexpected code paths or data), use WARN when a performance metric is hitting a soft limit (to warn you before you hit that hard limit), and use DEBUG to verbosely log anything else of general interest. Rarely you might also want to log in an extremely verbose manner data that wouldn't ordinarily be interesting, and this should be logged at a TRACE level. Generally speaking if this is the case then the code itself is due for a refactor. FATAL should normally be reserved for errors that prevent correct startup - generally if an application runs correctly at startup then any potential faults that you see and handle now become ERRORs because there is nearly always something better an application can do than log FATAL and exit. As the OP observed, if you have a potential fault that kills your application and you don't see and handle it then you don't have the opportunity to log FATAL anyway.

    By using a logging framework, many logging pitfalls can be avoided because the framework itself provides well tested facilities. eg, time-stamping, log rotation, file-handle management etc. In addition, using a framework allows the operator to tune the logging on a very granular level. This allows for a trade off to be made where if a performance impact is noted in a well used class then its logging can be reduced at runtime. Sure, there is still a small performance impact because the logging framework has to do a "if (logMessage.logLevel >= loggingClass.logLevel ) then {...}" comparision, but in the scale of things that impact is tiny.

    My profession is not about finding and fixing bugs. It is about understanding the software that is being delivered and deployed. It is about understanding what defects exist (or may exist) and the possible implications of those defects. It is about reducing the risk of defects through analysis. Analysis of the software's functionality, analysis of the software's performance, analysis of the processes used to produce the software itself. You will never be yelled at for releasing software with a well understood and documented defect, but the shit will hit the fan when you release major defects that are not understood.

    Logging is an _invaluable_ tool in this analysis. You'd be a fool to not use it effectively.

    1. Re:As much as practically possible by Gazzonyx · · Score: 2

      You will never be yelled at for releasing software with a well understood and documented defect, but the shit will hit the fan when you release major defects that are not understood.

      This is the most true thing I've read in a long time. I've found that being as up front as possible about bugs and defects is always the best policy.

      --

      If I mod you up, it doesn't necessarily mean I agree with what you've said, sorry.

    2. Re:As much as practically possible by Lonewolf666 · · Score: 2

      In my experience, once a defect is "well understood and documented", fixing it is usually easy enough. Or sometimes you can find a workaround that doesn't trigger the problematic behavior. Worst case, remove the feature that relies on the buggy code.

      If you don't have a solution, it becomes questionable to release the software at all. Unless the bug is merely a bit annoying rather than serious.
       

      --
      C - the footgun of programming languages
  23. Embedded debugging by shadoelord · · Score: 2

    I work on set top boxes, and not every platform we port to has a good debugger (hell, its been years since I've seen a good debugger). Our logging system is all in house; multiple "levels" for each log statment, (noise,information,warnings,fatals,etc), with each module creating its own log id and setting its "preference level". It works well, but:

    1) Useless logs.
    Engineers not taking the time to write logs that are useful. "Got to here", "Value=1", etc. A few of us write enum-to-string functions and pass them to the logging system for cleaner output.
    2) Running at the speed of 115200.
    We've only got a serial port most times, with multiple threads trying to access it, there's got to be some synchronization, and this generally affects threads of any priority. Using a logger that caches and outputs logs at its own pace is nice.
     

    --
    this is my sig, there are many like it, but this one is mine.
    1. Re:Embedded debugging by Perf · · Score: 2, Informative

      Engineers not taking the time to write logs that are useful. "Got to here", "Value=1", etc. A few of us write enum-to-string functions and pass them to the logging system for cleaner output.

      An Engineer does something that stupid?!!!
      Who told them they were engineers? The HR Dork?

  24. I asked slashdot a very similar question by emmjayell · · Score: 2, Interesting

    First - let me give you my own perspective. I recommend having each subsystem log in such a fashion that you can easily grep to include or ignore that subsystem. For example for one package the following LVLx messages were the first four characters as follows:

    LVL1 - basic startup and shutdown info ( a few lines per run)
    LVL2 - Interactions with the database
    LVL3 - Interactions with the file system
    LVL4 - Detailed database interactions including each sql statement
    LVL5 - amazingly verbose debug information including memory and variable allocations

    In almost all cases, I recommend being able to set each level on or off. Your sysadmin (maybe yourself) will appreciate that ability.

    If appropriate, I recommend an 'audit' record after each completed or aborted transaction. EG - after every order or every user change or whatever is important for accountability / business activity monitoring purposes.
    This is the original question .

  25. Re:youre doing it wrong by ciggieposeur · · Score: 2, Interesting

    There is no code in the world that I can think of that needs a log line after every two steps in a procedure.

    Any code in which timeouts can affect the result would require this kind of logging, which includes networking code or code that handshakes between multiple threads/processors. Example: debugging something like a new x/y/zmodem implementation is nigh impossible within a debugger because your side must respond within 10 seconds or the other side will start acting differently.

  26. Re:As little as practically possible by linear+a · · Score: 2, Informative

    Afraid you're describing a very natural behavior that's unlikely to disappear. Developers (not just software) tend to work until each constraint is just met and then stop to work on the next constraint. E.g., get the load time down to the maximum acceptable time, then stop working on it.

  27. ONLY IF... by Jane+Q.+Public · · Score: 2, Funny

    ... you are of the opposite sex, have no significant communicable diseases, and pay your own way.

    1. Re:ONLY IF... by CTalkobt · · Score: 2

      Just as an explanation for those who haven't clicked on Parent enough times to read the original post...the original thread stated "I am horny" ... hence the above comment.

      He was moderated off-topic, which seems fair however this being slash-dot I thought redundant might be a better moderation.

      *ducks*

      --
      There's a gorilla from Manilla whose a fella that stinks of vanilla and has salmonella.
  28. Re:I use God by T3Tech · · Score: 2

    I can see the t-shirts on ThinkGeek (which shares a corporate overlord with Slashdot) now...

    God is my debugger.

    --
    Of course I didn't RTFA... why would I do that? You really are new here aren't you? Don't let my UID fool you.
  29. operational errors by Spazmania · · Score: 2, Informative

    1. Distinguish between serious -operational- issues and other issues. The sysadmin doesn't need to know that you had a pointer problem; there's nothing he can do about it. He does, however, want to know that a message was received and the appropriate action taken. Or that a connection was attempted but failed.

    2. Be grep freindly. The first log entry related to a particular activity should have an ID of some sort in the log message which is then included in every additional log entry associated with that activity.

    --
    Moderating "-1, Disagree" is simple censorship. Have the guts to post your opinion.
  30. Re:As little as practically possible by Champion3 · · Score: 3, Interesting

    I'd be careful about using multi-core as a crutch: if the logging code isn't written properly, it can still be a bottleneck. Last year at my office we had to excise our old logging library because it turned out that each function call to the log acquired a global critical section even if the log level threshold wasn't met. Multi core wouldn't help because it was highly likely that any given call to the log would block the calling thread.

    --
    I'm going to the casino. Don't gamble.
  31. Be careful what you log... by gillbates · · Score: 3, Interesting

    It might come back to haunt you later.

    • If it could be useful for invading someone's privacy, law enforcement will expect to have access to it. Consider, for example, that the RIAA lawsuits were enabled by the fact that ISPs logged (and kept the logs) of the IP addresses and to whom they were assigned.
    • Consider how an attacker could use the logs as a means of figuring out how your software functions, and how to defeat it. "Buffer overflow on line __LINE__" - while well-intentioned - would be a bad message to log. If you must log defects, sanitize the output so that it doesn't reveal more information than is necessary for the reader to know.
    • In general, don't log normal operation beyond the startup and initialization messages. Users have this uncanny habit of looking to the logs for ways to blame the software for their own ineptitude. A verbose tirade of log messages will often provide them with ample ammunition for blame deflection and result in unnecessary service calls and potential misunderstanding. Especially if the log messages are cryptic and could be misconstrued to indicate that there is a bug with your software.
    • With respect to the above point, make sure that any errors which could be caused by misconfiguration or user error clearly indicate that the problem lies with the user or configuration.
    • When you do have to log a bug, include only the technical information necessary for the person doing the debugging. The point is to make it sufficiently technical that you have a starting point for debugging without giving the end user something with which they can hang you. Reporting a seg fault won't do you any good if you don't have the means to determine where and why it happened.
    --
    The society for a thought-free internet welcomes you.
  32. Re:As little as practically possible by telbij · · Score: 2, Interesting

    Afraid you're describing a very natural behavior that's unlikely to disappear. Developers (not just software) tend to work until each constraint is just met and then stop to work on the next constraint.

    And let's hope it never does disappear or we can kiss new software goodbye.

  33. Re:As little as practically possible by omeomi · · Score: 3, Insightful

    I wonder why, given the huge increase in the performance of computers over the last ten years and more, why it sill takes some games one to five minutes to load

    There are more textures, and they are stored at a higher resolution than they used to be; The 3D models have more triangles; there are more sound effects, and the quality is higher; there is more music, and the quality is higher...It takes time to load all of this into memory.

  34. None Inline, Use AOP by xero314 · · Score: 4, Interesting
    I just wanted to second the "as little as...possible" sentiment and take it one step further. DO NOT add any logging to your application code. If it is not essential to the logic it should not be in the code.

    That being said, you can add what ever logging you want as long as you do it outside the application code, such as through AOP (if you don't know what that is then google is your new best friend).

    Logging through external means has a number of benefits. First you application code is relieved from unnecessary clutter. Second the logging can be added or removed as fit for the environment with no need for any runtime checking, which is perfect for turning of all logging in production environments. And lastly it enforces good coding practices as it makes sure people break up code in a way that makes external logging possible, which is how code should be written anyway.

    The majority of all logging, dare I say all useful logging, is easy to summarize.
    • Starting Process... with the following conditions...
    • Starting Process... with the following conditions...

    This is perfect for function/method interception since it comes down to something more specific.

    • Executing Function... with the following arguments... (with one of those arguments being the state of the object the function is attached to in Object Oriented Programming)
    • Function... returned the following...

    So simply add the first logging to an interceptor that operates before the functions you want to log, and the second after the function.

    If you find yourself needing detail inside the function then you need to break the function up into sub routines, so you can use this generic logging on the sub routines instead, or as well as.

  35. Re:As little as practically possible by darkpixel2k · · Score: 5, Funny

    ...nothing's as frustrating as trying to analyze a log that came in from the field where there's just no information about what went wrong.

    [ 56.529336] WARNING: A-fib detected
    [ 56.568802] INFO: charging defib
    [ 56.741096] INFO: charging ccomplete
    [ 57.218803] ALERT: shocking!
    [ 58.061815] Buffer I/O error on /dev/paddles
    [ 58.163210] zapper[22402]: segfault at 000000c4 eip b321bf5f esp b320a870 error 6
    BUG: unable to handle kernel NULL pointer dereference at virtual adress 00000000
    printing eip: c013186b *pde = 00000000
    Oops: 0000 [#1] SMP
    Modules linked in: battery ipv6 paddles ac button battery cardiac_monitor thermal processor zapper fan

    Man, I'd feel bad after that output...

    --
    There's no place like ::1 (I've completed my transition to IPv6)
  36. Re:As little as practically possible by Dun+Malg · · Score: 2, Informative

    Afraid you're describing a very natural behavior that's unlikely to disappear. Developers (not just software) tend to work until each constraint is just met and then stop to work on the next constraint.

    And let's hope it never does disappear or we can kiss new software goodbye.

    Some of that behavior I've seen, we'd be better off if it disappeared. Sometimes, simply expanding till limits are met is like the old saying "some day, computers will be the size of buildings, and have millions of vacuum tubes!"

    Perhaps I'm just pessimistic because where I work they're in the process of replacing the huge, unwieldy FileMaker monstrosity that handles payroll.... with an even bigger, more unwieldy FileMaker monstrosity that does the same thing, but requires us to feed it more information (more detailed job codes, time tracked in 6 minute increments, etc). All this extra data will be used to generate reports explaining why we're always releasing late. Never mind that we've been badgering them to hire more people for months. No, it's clearly a time management issue! As the PHB in Dilbert once said, "I want hourly reports on why we're behind schedule!"

    --
    If a job's not worth doing, it's not worth doing right.
  37. Re:As little as practically possible by TapeCutter · · Score: 2, Insightful

    "Turning on verbose logging doesn't help you after the process has gone tits up."

    How can you demonstrate that you have fixed the reported bug if you can't recreate it in the first place?

    --
    And did you exchange a walk on part in the war for a lead role in a cage? - Pink Floyd.
  38. Re:As little as practically possible by zotz · · Score: 4, Funny

    I think you might be missing the main reason. If we don't reduce software logging, pretty soon there will be no old growth software left.

    all the best,

    drew

    --
    FreeMusicPush If you want to see more Free Music made, listen to Free
  39. Re:As little as practically possible by dubl-u · · Score: 2, Interesting

    I wonder why, given the huge increase in the performance of computers over the last ten years and more, why it sill takes some games one to five minutes to load.

    The goal of almost any commercial product isn't to be 100% awesome in every possible way. It's to be adequate on most measures and awesome in the few that buyers care most about.

    Game buyers care about volume and quality of content a lot more than load time. So even if some engineer figured out a way to cut load time in half, somebody would just add more content and bump up bit rates and quality levels until it was back to a tolerable load time.

  40. Re:As little as practically possible by FourDegreez · · Score: 2, Insightful

    Consider, the attitude of "just throwing more processing power" at something is driving up electricity usage at data centers and office buildings across the country. A responsible programmer in this day and age should consider the energy footprint their code will have. Yes, I am completely serious.