Josh wrote:

> In the Struts example code wherever debug/log information is being printed to
> the log, the code appears:
>
> if (servlet.getDebug() >= 1)
>     servlet.log("debug/log message");
>

This is also my typical pattern throughout the Struts code itself.

>
> I was wondering if that was advantageous over:
>
> servlet.log("debug/log message", 1);
>
> I am under the impression that the two samples work the same, and would prefer
> to use the second, however I was wondering if there was some sort of
> performance issue, etc . . .
>

If you do this as a method call, any expression required to calculate
the
debugging message will be performed, whether or not you ever really
write the log
message out.  This can be pretty expensive if you are doing something
like this:

    servlet.log("Name=" + name + " and value=" + value, 1);

which does a bunch of string concatenations.  You don't mind paying the
price if
you are really doing the debugging output (because it's just for testing
anyway),
but you really do *not* want to spend the time doing the string
concatenations in
production.  Using the "if" approach avoids that.

>
> Thanks,
> Josh
>

Craig McClanahan

Reply via email to