add object instance id to log4net log -


i trying use log4net distributed logging on cluster.

my software stack composed of isolated agents spreed around cluster unique instance id. add instance id of each object logging log being generated want inherited classes use same value object instance id following best practice of adding static logger every class of mine , if class inherit base class, have own logger below

 private static ilog _log =logmanager.getlogger(system.reflection.methodbase.getcurrentmethod().declaringtype); 

so can not use logger name. also, not want have add object instance id every log make , automatically done logn4net log.

i can use logger context , instance id not global , not belong espcific thread. how should go this?

you can add nested diagnostic contexts business classes provide context information on going on. log messages enriched ndc information, example can add current id ndc context , when log, log message enriched.

using(ndc.push("my context message, , id is:"+object.id)) {     ... log calls have 'my context message, , id is:...' included ... }  

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -