• trwtf (unregistered) in reply to evertras
    evertras:
    ... it was crashing in such a strange place that I wouldn't have found it if I hadn't done SuperLogging.

    I can usually find Canada without superlogging. Starting in the US and heading north is one way.

  • (cs) in reply to cappeca
    cappeca:
    I don't see the WTF here, as long as it's temporary, has a Log/No log switch, and helped find bugs. If you have to do that in order to have a robust production system in the end, do it.
    Neither do I, except that the majority of the code we see here is for logging only.

    One way that the logging here is excessive is when the code needlessly announces to the log file what function it's going to call next. Let's look at an example:

    TFA:
    logFile.debug("Getting major classifications.");
    majorClassifications = cl.getMajorClassifications();
    (comments/whitespace lines snipped)
    I'd be willing to bet that inside "getMajorClassifications()" it has (practically) the same log messages. Not only is the code cluttered, but it sounds like the log files will be a cluttered mess as well. Personally, if I'm trying to resolve a defect, especially an issue in production, I want log files that are useful to me.

    Perhaps Eric should have submitted an excerpt of the log file too, so we could see just how hideous it really is.

  • (cs)

    Minutely log rotations?

  • (cs) in reply to trwtf
    trwtf:
    I can usually find Canada without superlogging. Starting in the US and heading north is one way.

    OK, I started in Anchorage and I'm heading North!

    All I see is water so far...

  • darjien (unregistered)

    It might also be useful to log some information that's handy at runtime beyond merely where you are in the code?

    Surely debug-level logging should contain some run-specific info?

  • (cs) in reply to WhiskeyJack
    WhiskeyJack:
    trwtf:
    I can usually find Canada without superlogging. Starting in the US and heading north is one way.

    OK, I started in Anchorage and I'm heading North!

    All I see is water so far...

    Updated directions:

    angle = random(0, pi);
    
    while (!inCanada()) {
        step_forward();
        turn(angle);
    }
    
  • (cs) in reply to Anonymous
    Anonymous:
    Overall you'll be a far less productive coder if you favour logging over debugging.
    Considering that the part of your comment that I snipped was referring to "debugging" in the context of a "debugging tool", please provide evidence for the statement above.

    Personally, I've used many methods of debugging and have never found using a debugger to be in any way superior to methods such as trace statements (or "logging" as you call it).

  • (cs) in reply to TST
    TST:
    For a medical product, these logs are great because you can track everything that was done.

    Maybe I'm too anal, but I can't really see the WTF here. If the code passage is mission-critical I can understand the massive logging capabilities.

    Speaking as a programmer for a company in the PBM industry*: please don't make me slap you. If your goal is to track everything that's done, you want to save the crucial actions as records in a searchable, well-designed database. Dumping everything into a log file would be inane, even for a mission-critical application. You might do that in test phase (and we do have long and intensive test phases).

    *That code could conceivably fit into one of our applications. Not one I work on ... But all of the developers I've interacted with who would be involved in that, strike me as way too smart to churn out this abortion. So I'm going to assign this snippet to one of our competitors. And then buy some more of my company's stock.

  • w.irving (unregistered)

    Obviously those debug and info methods in turn contain some sort of logging to record instances where they would fail, leaving dear Chris with an empty log.

  • Spoc42 (unregistered) in reply to AlexC
    AlexC:
    I do hate it when people come on and defend mad practices in coding but I once had to fix a piece of problem code existed in a routine that, when run in a debugging tool (I don't want to say which one), would crash and die horribly. I spent some really long hours trying to fix the issue and then as a last gasp attempt I just ran it outside the debugger it worked perfectly. I was stung by that and it stayed with me to never trust debuggers 100%. However, obviously this code should never, ever make it to a production build.
    I have had the opposite effect today. Access 2003 crashing while opening a form (sometimes) and crashing when I pressed a particular button (always). When running in debug mode, everything worked just fine; when running full tilt, it crashed. Lost me about 6 hours until I got 10 mS delays in the right places to *slow* it down.
  • cdr (unregistered) in reply to WhiskeyJack
    WhiskeyJack:
    trwtf:
    I can usually find Canada without superlogging. Starting in the US and heading north is one way.

    OK, I started in Anchorage and I'm heading North!

    All I see is water so far...

    Check your compass; you're obviously not going north.

  • Anonymous (unregistered) in reply to boog
    boog:
    Anonymous:
    Overall you'll be a far less productive coder if you favour logging over debugging.
    Considering that the part of your comment that I snipped was referring to "debugging" in the context of a "debugging tool", please provide evidence for the statement above.

    Personally, I've used many methods of debugging and have never found using a debugger to be in any way superior to methods such as trace statements (or "logging" as you call it).

    Let's not argue over semantics, most people refer to log statements as "logging" and attaching a debugger as "debugging". I wonder why that is? You're right that the general process of "debugging" an application can take on any form - just running it and watching the behaviour could be considered "debugging" but as said, it's just semantics so no point in getting hung up about it.

    The obvious benefit of a debugger is that it's like having a log statement on every single line!!! Logging requires an explicit line of code where you need to log some info, that's an overhead. Debugging (as in "with a debugger") allows you to inspect the state of the application on every single line, including the value of variables and every other bit of info you could possibly want. It's pretty obvious which is the more economic method in terms of time and effort.

    Of course, there will always be times when you can't attach a debugger, but if you can attach a debugger then it beats logging by a long shot. I don't see this as a matter of taste, more a matter of fact.

  • (cs) in reply to Bus Logic
    Bus Logic:
    nitehawk:
    In fact in my career I would say I get brow beat due to my age without regard to my experience. (10 years industry experience at 29). Then when I do get to an age where I can perform the same, I get scoffed because of the low amount of time at the company.
    That's funny, I'm also 29 years old with 10 years industry experience; the only difference is that I'm a senior developer and a team lead. Maybe it's not your age that's the problem? No offence meant by that, I just mean maybe you're working for a crappy company that doesn't recognise your talent?

    Maybe both your companies work on the Peter Principle?

  • Vjg (unregistered) in reply to trwtf
    trwtf:
    evertras:
    ... it was crashing in such a strange place that I wouldn't have found it if I hadn't done SuperLogging.

    I can usually find Canada without superlogging. Starting in the US and heading north is one way.

    Unless you're in Alaska or Hawaii.

  • jim (unregistered)

    Does anyone else just switch off when folks bang on about being a "Senior Developer" or "Dev Lead".?

    A guy I know has his current title on LinkedIn set as "Senior Lead Developer".

  • Banjer (unregistered) in reply to Spoc42
    Spoc42:
    I have had the opposite effect today. Access 2003 crashing while opening a form (sometimes) and crashing when I pressed a particular button (always). When running in debug mode, everything worked just fine; when running full tilt, it crashed. Lost me about 6 hours until I got 10 mS delays in the right places to *slow* it down.

    Ouch. You better go back and look for the real problem...

  • grumpy (unregistered) in reply to paul
    paul:
    AARGH! The use of whitespace and commentary seems to associate each log entry with the preceding line, but the content is actually associated with the following line.
    Look closer. Only sometimes. Other times he gets it right. As an admin and maintenance programmer my considered opinion of this kind of "developer" is: shooting is far too good for them...
  • (cs)

    Wow, it's funny how much faith people put in titles.

    Anyway, TRWTF is Vector. Pretty sure people stopped using that circa 1995.

  • Mike (unregistered) in reply to cdr
    WhiskeyJack:
    Check your compass; you're obviously not going north.
    Check your globe, in both cases of the northpole (magnetic and real) he will never hit Canada.
  • grumpy (unregistered) in reply to Banjer
    Banjer:
    Spoc42:
    Lost me about 6 hours until I got 10 mS delays in the right places to *slow* it down.
    Ouch. You better go back and look for the real problem...
    Heehee, good look on that. Got the same problem in Lotus Notes where Magical Prints are the norm. If something crashes inexplicably, we add a Print "Hello there" just before the sore spot. It works often enough to make it worth our while. Sometimes I cry a little after work...
  • joe blow (unregistered)

    better too much than not enough

  • BentFranklin (unregistered)

    If your logs start building up use this pattern to flush them:

    logFile.debug("Drug: " + drug.ExLax);
  • grumpy (unregistered) in reply to grumpy

    *luck even. Bother.

    <OUT OF COFFEE ERROR; OPERATOR HALTED>

  • tim (unregistered) in reply to qbolec
    qbolec:
    I found, that Math has a log function, but it doesn't do what I need, though.
    lol - that explains it. I was wondering why, whenever i look at my log files, they are just full of floating point numbers :D
  • drachenstern (unregistered) in reply to Ian
    Ian:
    Inigo Montoya:
    You keep using this word, I do not think it means what you think it means.

    http://dictionary.reference.com/browse/Inconceivable

    Inconceivable!
    FTFY

  • cdr (unregistered) in reply to Mike
    Mike:
    WhiskeyJack:
    Check your compass; you're obviously not going north.
    Check your globe, in both cases of the northpole (magnetic and real) he will never hit Canada.
    Didn't say he would.
  • Spearhavoc! (unregistered) in reply to trwtf
    trwtf:
    evertras:
    ... it was crashing in such a strange place that I wouldn't have found it if I hadn't done SuperLogging.

    I can usually find Canada without superlogging. Starting in the US and heading north is one way.

    Not at all true in all instances of US.

  • cdr (unregistered) in reply to cdr
    Mike:
    WhiskeyJack:
    Check your compass; you're obviously not going north.
    Check your globe, in both cases of the northpole (magnetic and real) he will never hit Canada.
    And you screwed up the quoting, moron.
  • trwtf (unregistered) in reply to Vjg
    Vjg:
    trwtf:
    evertras:
    ... it was crashing in such a strange place that I wouldn't have found it if I hadn't done SuperLogging.

    I can usually find Canada without superlogging. Starting in the US and heading north is one way.

    Unless you're in Alaska or Hawaii.

    Right, I've added logging for those cases.

  • tekHedd (unregistered) in reply to Anonymous

    He said that's how you do it, not that you /must/ do it every time. See how the word 'Senior' is quoted, with ironic effect. Does this bother you?

    Also, thanks for demonstrating an important point: this technique does not work if you randomly quote a bunch of words. It is important to understand irony and sarcasm before using this technique.

  • tekHedd (unregistered) in reply to Anonymous
    Anonymous:
    Inigo Montoya:
    To show that you're using a word ironically, you put it in quotes.
    Where the hell did you learn English? I'd like to see a citation for that. I understood perfectly well he was being sarcastic, quotes would have just been dumb in that context. I hate it when people "feel" that thay "have" to "quote" "everything". It ruins the flow of the writing.

    ^^ Please mentally insert the above quotes into my previous comment. Thanks. (:/ Need caffeine!)

  • Dazed (unregistered) in reply to Mike
    Mike:
    WhiskeyJack:
    Check your compass; you're obviously not going north.
    Check your globe, in both cases of the northpole (magnetic and real) he will never hit Canada.
    Double fail: (a) you've got your attributions wrong; (b) the 'check your compass' remark was quite correct - heading north from Anchorage takes you overland.
  • Spearhavoc! (unregistered) in reply to Maurits
    Maurits:
    WhiskeyJack:
    trwtf:
    I can usually find Canada without superlogging. Starting in the US and heading north is one way.

    OK, I started in Anchorage and I'm heading North!

    All I see is water so far...

    Updated directions:

    angle = random(0, pi);
    
    while (!inCanada()) {
        step_forward();
        turn(angle);
    }
    

    Going in a circle makes canada easier to find?

  • Bus Logic (unregistered) in reply to Salami
    Salami:
    Bus Logic:
    nitehawk:
    In fact in my career I would say I get brow beat due to my age without regard to my experience. (10 years industry experience at 29). Then when I do get to an age where I can perform the same, I get scoffed because of the low amount of time at the company.
    That's funny, I'm also 29 years old with 10 years industry experience; the only difference is that I'm a senior developer and a team lead. Maybe it's not your age that's the problem? No offence meant by that, I just mean maybe you're working for a crappy company that doesn't recognise your talent?

    Maybe both your companies work on the Peter Principle?

    I'm not quite sure whether I should be flattered or offended.

    jim:
    Does anyone else just switch off when folks bang on about being a "Senior Developer" or "Dev Lead".?
    Yeah, I hear this a lot from juniors.
  • Anonymous (unregistered) in reply to tekHedd
    tekHedd:
    Also, thanks
    You're very welcome my friend, very welcome indeed. If you need any further tutelage you just let me know.
  • (cs) in reply to Mike
    Mike:
    WhiskeyJack:
    Check your compass; you're obviously not going north.
    Check your globe, in both cases of the northpole (magnetic and real) he will never hit Canada.
    Indeed, he won't. But if you start at Anchorage and go north, you see a whole lot of land (most of Alaska), then maybe a bit of water (depending on the season), then a whole lot of ice, then a place where you can only go south.
  • David (unregistered)

    The syntax coloring actually makes the code easier to read, since the logging is somewhat lighter than the real code. In many editors, it would be very hard to find the code through the sea of logs.

  • Curt (unregistered) in reply to Alastair

    Ah, but if you log all successful statements, the absence of a log entry clearly shows an error.

    <head explodes>
  • (cs) in reply to Inigo Montoya
    Inigo Montoya:
    notme:
    Inigo Montoya:
    Since the department is governed by meritocracy, Christophe’s eight years makes him a “Senior” Developer and, therefore, correct.

    You keep using this word, I do not think it means what you think it means.

    http://dictionary.reference.com/browse/meritocracy

    I think he knows very well what that word means and was being sarcastic.

    To show that you're using a word ironically, you put it in quotes.

    I don't think that explicitly pointing out sarsasm sucks at all.

  • trwtf (unregistered) in reply to frits
    frits:
    Inigo Montoya:
    notme:
    Inigo Montoya:
    Since the department is governed by meritocracy, Christophe’s eight years makes him a “Senior” Developer and, therefore, correct.

    You keep using this word, I do not think it means what you think it means.

    http://dictionary.reference.com/browse/meritocracy

    I think he knows very well what that word means and was being sarcastic.

    To show that you're using a word ironically, you put it in quotes.

    I don't think that explicitly pointing out sarsasm sucks at all.

    And, just so nobody's confused, that comment itself was sarcastic. It's self-reference, get it?

    The misspelling was just unfortunate, and not sarcastic at all.

  • anonymously Yours (unregistered)

    I wonder how long it will take him to review the production logs to figure out why everything's running so slow.

  • (cs)

    I don't know what bugs me the most. The obscene amount of log calls or the misplaced comments.

  • (cs) in reply to trwtf
    trwtf:
    frits:
    Inigo Montoya:
    notme:
    Inigo Montoya:
    Since the department is governed by meritocracy, Christophe’s eight years makes him a “Senior” Developer and, therefore, correct.

    You keep using this word, I do not think it means what you think it means.

    http://dictionary.reference.com/browse/meritocracy

    I think he knows very well what that word means and was being sarcastic.

    To show that you're using a word ironically, you put it in quotes.

    I don't think that explicitly pointing out sarsasm sucks at all.

    And, just so nobody's confused, that comment itself was sarcastic. It's self-reference, get it?

    The misspelling was just unfortunate, and not sarcastic at all.

    Good luck with that Assburger's.

  • Darth MS (unregistered) in reply to anonymously Yours
    anonymously Yours:
    I wonder how long it will take him to review the production logs to figure out why everything's running so slow.
    Well, the nice thing about having all of those logs is you can look and see how long it takes to execute each statement. Who needs profiling when you have logging!
  • trwtf (unregistered) in reply to frits
    frits:
    trwtf:
    frits:
    Inigo Montoya:
    notme:
    Inigo Montoya:
    Since the department is governed by meritocracy, Christophe’s eight years makes him a “Senior” Developer and, therefore, correct.

    You keep using this word, I do not think it means what you think it means.

    http://dictionary.reference.com/browse/meritocracy

    I think he knows very well what that word means and was being sarcastic.

    To show that you're using a word ironically, you put it in quotes.

    I don't think that explicitly pointing out sarsasm sucks at all.

    And, just so nobody's confused, that comment itself was sarcastic. It's self-reference, get it?

    The misspelling was just unfortunate, and not sarcastic at all.

    Good luck with that Assburger's.

    Ah, sarcasm again. Our frist is a bit of a one-trick pony, it seems.

  • AWK (unregistered)

    Having to maintain pre-ANSI C running on SCO Openserver boxes, I don't have access to all of them newfangled debuggers and stuff you talk about. So to me this looks pretty normal.

    Add to that, the fact that the systems in question are located at multiple sites, where the only remote connection is a modem that can do 4800 baud on a good day. Then you will really start appreciating this log pattern.

  • :P (unregistered)
    Maurits:
    while (!inCanada()) {
    
    angle = random(-pi, pi);
    step_forward();
    turn(angle);
    

    }

    FTFY.

  • (cs) in reply to dave
    dave:
    this is not what you mean: "meritocracy" this is what you mean: "gerontocracy"

    further information: http://en.wikipedia.org/wiki/Gerontocracy

    You're a fucking moron. And since apparently you need this sort of clarification, I do not mean that you're a moron that's currently engaged in sexual intercourse.

  • (cs) in reply to Anonymous
    Anonymous:
    Let's not argue over semantics...
    Very much agreed. My point on semantics was not meant as criticism, just to clarify that I assumed (based on the omitted part of your comment) which context you meant.
    Anonymous:
    Debugging (as in "with a debugger") allows you to inspect the state of the application on every single line, including the value of variables and every other bit of info you could possibly want. It's pretty obvious which is the more economic method in terms of time and effort.
    Obviously it's better if your method of measuring the economic value (in terms of time and effort) is based on how many data you get from the debugger. However, I personally find it time-consuming to sift through a lot of meaningless information, so aside from situations where having every bit of info you could possibly want is useful, I don't see the economic benefits myself.

    I'd much rather take a few seconds to sprinkle some assert statements throughout the known problem area and let the error conditions surface on their own (but even that doesn't work in all situations).

    Anonymous:
    Of course, there will always be times when you can't attach a debugger, but if you can attach a debugger then it beats logging by a long shot. I don't see this as a matter of taste, more a matter of fact.
    I respectfully disagree. That isn't to say that debuggers don't have merits; they are certainly useful when dealing with closed third-party libraries (where you do need every bit of information you could possibly want).

    My problem with debuggers is that for many programmers, running the debugger becomes a knee-jerk reaction whenever something seems amiss. No thought goes into where the root cause of the problem might be and what might be the best method to identify it. They just fire up the debugger and step through the code.

    My point is that there are so many methods for debugging code; all of them can be just as useful as a debugger (in some situations more so, in some situations less).

  • trwtf (unregistered) in reply to boog
    boog:
    My point is that there are so many methods for debugging code; all of them can be just as useful as a debugger (in some situations more so, in some situations less).

    As long as your code ends up de-buggered in the end, that's all that matters.

Leave a comment on “Log Everything”

Log In or post as a guest

Replying to comment #:

« Return to Article