log arguments

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

log arguments

ErikL
Hi,

I was wondering what the purpose is of arguments you can provide to the log methods.

I read the introduction docs, but couldn't found any info on it (perhaps I overlooked)

grtz
Reply | Threaded
Open this post in threaded view
|

Re: log arguments

Jarek Kowalski
Administrator
Can you be more specific? Which arguments you don't understand?

The idea was to mimic the Console.WriteLine() API, which is commonly used
for first line of diagnostics in .NET. It lets you pass positional
parameters which are then formatted according to the specified format
string.

The benefit of this approach (when compared to direct string concatenation)
is speed. Since NLog can eliminate logging messages at runtime, there's a
chance that the entire concatenation/formatting won't be necessary. In
particular:

string aaa = "aaa";
string bbb = "bbb";

logger.Debug("This is parameter {0} and this is another one {1}", aaa, bbb);

can be way faster than:

logger.Debug("This is parameter " + aaa + " and this is another one " +
bbb);

if debugging for this particular logger is disabled. It's also a bit slower
whan the log message DOES need to be logged, but since logging usually
involves writing to a file or other "slow" medium, this is much smaller
issue.

Jarek

----- Original Message -----
From: "ErikL" <[hidden email]>
To: <[hidden email]>
Sent: Friday, April 14, 2006 3:33 PM
Subject: [Nlog-list] log arguments


>
> Hi,
>
> I was wondering what the purpose is of arguments you can provide to the
> log
> methods.
>
> I read the introduction docs, but couldn't found any info on it (perhaps I
> overlooked)
>
> grtz
> --
> View this message in context:
> http://www.nabble.com/log-arguments-t1449722c6167.html#a3916604
> Sent from the NLog-list forum at Nabble.com.
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting
> language
> that extends applications into web and mobile media. Attend the live
> webcast
> and join the prime developer group breaking into this new coding
> territory!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
> _______________________________________________
> Nlog-list mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/nlog-list
>



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Nlog-list mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nlog-list
NLog Blog
Reply | Threaded
Open this post in threaded view
|

Re: log arguments

ErikL
Hi,

This was the info I was looking for. I'm blushing a bit here, because I didn't realized it was the same behaviour as the formatted string.

Anyway, perhaps a sentence could be added in the documentation to point out this "trivial" thing.

thnx