logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Grabowski <rongrabow...@yahoo.com>
Subject Re: ILog Wrapping
Date Sat, 02 Jun 2012 23:10:29 GMT
The original poster specifically mentioned he did not want to have to walk to the call stack.
Log4net internally walks the call stack so there's no need to walk it twice.

The Stack Overflow article is correct. Here's another example:


The key concept is needing to pass in the Type of your wrapper to the actually log method
so log4net knows to skip over that stack frame when its processing call information.

 From: Martin Milan <Martin.Milan@enservegroup.com>
To: Log4NET User <log4net-user@logging.apache.org> 
Sent: Friday, June 1, 2012 4:13 AM
Subject: RE: ILog Wrapping

Can you not walk the call stack until you come across a method that is not from the same namespace
as your wrapper?
Just an idea…
From:Andreas HOELZLWIMMER [mailto:andreas.hoelzlwimmer@racon.at] 
Sent: 01 June 2012 08:36
To: log4net-user@logging.apache.org
Subject: ILog Wrapping
I need to switch our logger to Log4Net in our application. I need to implement our personal
logging interface, which means I need to wrap the Logger. The logger requires to display method
name and namespace. With the "usual" way it always shows the method and namespace of the wrapper,
not the method called. The option found on stackoverflow (http://stackoverflow.com/questions/157232/how-to-log-methodname-when-wrapping-log4net)
does not help and I wanted to know if there is a way to log the correct method/namespace without
having to go back in the call stack. Is there a best practise for wrapping ILog? 
best regards, 

Der Austausch von Nachrichten mit o.a. Absender via e-mail dient ausschließlich Informationszwecken.
Rechtsgeschäftliche Erklärungen dürfen über dieses Medium nicht ausgetauscht werden.

Correspondence with a.m. sender via e-mail is only for information purposes. This medium is
not to be used for the exchange of legally-binding communications.Enserve Group Legal Disclaimer
EnServe Group Limited ("EnServe"), registered in England and Wales with  registration number
3250709.EnServe's registered office is at Hertsmere House, Shenley Road, Borehamwood, Herts,
WD6 1TE, United  Kingdom and a list of EnServe's subsidiaries and their registered particulars
is available for inspection at this location. This  email and any attachments to it are confidential
and are intended solely for the use of the individual to whom it is addressed.  Any views
or opinions expressed are solely those of the author and do not necessarily represent those
of EnServe or its  subsidiaries. If you are not the intended recipient of this email, you
must neither take any action based upon its contents, nor  copy or show it to anyone. Please
contact the sender if you believe you have received this email in error. 

This message has been scanned by Symantec Mail Security
View raw message