c# - What should I identify with the id argument in TraceSource.TraceEvent method? -


i use tracesource class logging in .net projects.

however point has never been clear me is, intent of id parameter in traceevent method. currently, set 0.

but expected or typical useful usage of it?

i can think of few possibilities:

  • it id occurrence of event (i.e. same line of code produces different id on each execution);
  • it id method call (i.e. can infer line of code id);
  • it id family of similar events (e.g. error messages database absent share same id);
  • it id set of events related logical operation, in combination traceeventtype.(start|stop|suspend|resume|transfer) enumeration values;

i've asked myself same question , didn't found clarify in microsoft documentation. i've manage find article written microsoft mvp, richard grimes: "the id parameter whatever choose be, there no compulsion particular id associated particular format message." uses 0, id argument, in examples.

in msdn articles, i've seen used random, not providing additional info. believe can use in way helps best when reading logs, long maintain same code convention. may prove useful afterwards in trace filtering, if want use sourcefilter.shouldtrace method, accept id argument too.

i use describe error type, if have error, or use 0 else.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -