Return-Path: X-Original-To: apmail-logging-log4net-user-archive@www.apache.org Delivered-To: apmail-logging-log4net-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 024B098CA for ; Mon, 4 Jun 2012 14:19:37 +0000 (UTC) Received: (qmail 44893 invoked by uid 500); 4 Jun 2012 14:19:36 -0000 Delivered-To: apmail-logging-log4net-user-archive@logging.apache.org Received: (qmail 44848 invoked by uid 500); 4 Jun 2012 14:19:36 -0000 Mailing-List: contact log4net-user-help@logging.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Log4NET User" List-Id: Delivered-To: mailing list log4net-user@logging.apache.org Received: (qmail 44837 invoked by uid 99); 4 Jun 2012 14:19:36 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Jun 2012 14:19:36 +0000 X-ASF-Spam-Status: No, hits=0.2 required=5.0 tests=FSL_RCVD_USER,HTML_FONT_FACE_BAD,HTML_MESSAGE,RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of andreas.hoelzlwimmer@racon.at designates 193.110.129.115 as permitted sender) Received: from [193.110.129.115] (HELO grzmail2.grz.co.at) (193.110.129.115) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Jun 2012 14:19:29 +0000 Received: from secmail4.grz.co.at (unknown [10.18.102.106]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by grzspam2.rbgooe.at (Postfix) with ESMTP id 05EE4ED0041 for ; Mon, 4 Jun 2012 16:19:08 +0200 (CEST) Received: from smtp-hub1.grz.co.at (unknown [10.18.18.10]) by secmail4.grz.co.at (Postfix) with ESMTP for ; Mon, 4 Jun 2012 16:18:46 +0159 (CEST) In-Reply-To: To: "Log4NET User" Subject: Antwort: Re: ILog Wrapping MIME-Version: 1.0 X-KeepSent: E1F6D1F6:B99EC8C6-C1257A13:004E6E87; type=4; name=$KeepSent From: Andreas HOELZLWIMMER Message-ID: Date: Mon, 4 Jun 2012 16:19:07 +0200 Content-Type: multipart/alternative; boundary="=_alternative 004EA7F4C1257A13_=" Dies ist eine mehrteilige Nachricht im MIME-Format. --=_alternative 004EA7F4C1257A13_= Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable Hello, I just changed my code to incorporate log4net.Core.ILogger instead of the=20 comfort class log4net.ILog. With the Logger Wrapper Type always entered at= =20 the call of the log method, it now works. using only the ILog interface=20 shows broken (as explained) behavior. I may be wrong, but this isn't=20 supposed to happen this way, is it? Andreas HOELZLWIMMER =20 04.06.2012 09:13 Bitte antworten an "Log4NET User" An "Log4NET User" Kopie Thema Antwort: Re: ILog Wrapping The way I'm doing it now is by calling this line:=20 private static readonly log4net.ILog log =3D=20 log4net.LogManager.GetLogger(System.Reflection.MethodBase .GetCurrentMethod().DeclaringType);=20 From=20what I see in your example, the important thing is to give the logge= r=20 your current logging method Type, which is what I do. The difference is=20 that instead of using the ILogger interface I use the ILog Interface,=20 mostly because I wanted to use LogDebug, LogInfo, ... for comfort. Doing=20 it with the given line, I expect it to work similarily to the example,=20 namely=20 private readonly static Type declaringType =3D typeof(Log4NetLogger);=20 _logger.Log(declaringType, log4net.Core.Level.Info, message, e);=20 Am I wrong to expect it to work in the same way?=20 Ron Grabowski =20 03.06.2012 01:11=20 Bitte antworten an "Log4NET User" An Log4NET User =20 Kopie Thema Re: ILog Wrapping The original poster specifically mentioned he did not want to have to walk= =20 to the call stack. Log4net internally walks the call stack so there's no=20 need to walk it twice.=20 The Stack Overflow article is correct. Here's another example:=20 http://svn.apache.org/viewvc/ibatis/cs/ibatisnet-1/trunk/src/IBatisNet.Comm= on.Logging.Log4Net/=20 The key concept is needing to pass in the Type of your wrapper to the=20 actually log method so log4net knows to skip over that stack frame when=20 its processing call information.=20 From: Martin Milan To: Log4NET User =20 Sent: Friday, June 1, 2012 4:13 AM Subject: RE: ILog Wrapping=20 Can you not walk the call stack until you come across a method that is not= =20 from=20the same namespace as your wrapper?=20 =20 Just an idea?=20 =20 =20 From: Andreas HOELZLWIMMER [mailto:andreas.hoelzlwimmer@racon.at]=20 Sent: 01 June 2012 08:36 To: log4net-user@logging.apache.org Subject: ILog Wrapping=20 =20 Hi,=20 I need to switch our logger to Log4Net in our application. I need to=20 implement our personal logging interface, which means I need to wrap the=20 Logger. The logger requires to display method name and namespace. With the= =20 "usual" way it always shows the method and namespace of the wrapper, not=20 the method called. The option found on stackoverflow ( http://stackoverflow.com/questions/157232/how-to-log-methodname-when-wrappi= ng-log4net ) does not help and I wanted to know if there is a way to log the correct=20 method/namespace without having to go back in the call stack. Is there a=20 best practise for wrapping ILog?=20 best regards,=20 Andreas=20 Der Austausch von Nachrichten mit o.a. Absender via e-mail dient=20 ausschlie=DFlich Informationszwecken. Rechtsgesch=E4ftliche Erkl=E4rungen d= =FCrfen=20 =FCber dieses Medium nicht ausgetauscht werden. Correspondence with a.m. sender via e-mail is only for information=20 purposes. This medium is not to be used for the exchange of=20 legally-binding communications.=20 EnServe Group Limited ("EnServe"), registered in England and Wales with=20 registration number 3250709.EnServe's registered office is at Hertsmere=20 House, Shenley Road, Borehamwood, Herts, WD6 1TE, United Kingdom and a=20 list of EnServe's subsidiaries and their registered particulars is=20 available for inspection at this location. This email and any attachments=20 to it are confidential and are intended solely for the use of the=20 individual to whom it is addressed. Any views or opinions expressed are=20 solely those of the author and do not necessarily represent those of=20 EnServe or its subsidiaries. If you are not the intended recipient of this= =20 email, you must neither take any action based upon its contents, nor copy=20 or show it to anyone. Please contact the sender if you believe you have=20 received this email in error.=20 This message has been scanned by Symantec Mail Security Der Austausch von Nachrichten mit o.a. Absender via e-mail dient=20 ausschlie=DFlich Informationszwecken. Rechtsgesch=E4ftliche Erkl=E4rungen d= =FCrfen=20 =FCber dieses Medium nicht ausgetauscht werden. Correspondence with a.m. sender via e-mail is only for information=20 purposes. This medium is not to be used for the exchange of=20 legally-binding communications. Der Austausch von Nachrichten mit o.a. Absender via e-mail dient ausschlie= =DFlich Informationszwecken. Rechtsgesch=E4ftliche Erkl=E4rungen d=FCrfen = =FCber 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 communi= cations. --=_alternative 004EA7F4C1257A13_= Content-Type: text/html; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable
Hello,

I just changed my code to incorporate log4net.Core.ILogger instead of the comfort class log4net.ILog. With the Logger Wrapper Type always entered at the call of the log method, it now works. using only the ILog interface shows broken (as explained) behavior. I may be wrong, but this isn't supposed to happen this way, is it?





Andreas HOELZLWIMMER <andreas.= hoelzlwimmer@racon.at>

04.06.2012 09:13
Bitte antworten an "Log4NET User" <log4net-user@logging.apache.org>

An
"Log4NET User" <log4net= -user@logging.apache.org>
Kopie
Thema
Antwort: Re: ILog Wrapping




The way I'm doing it now is by calling th= is line:

private static readonly log4net.ILog log =3D
           log4net.
LogManager.GetLogg= er(System.Reflection.Metho= dBase.GetCurrentMethod().DeclaringType);

From=20what I see in your example, the important thing is to give the logger your current logging method Type, which is what I do. The difference is that instead of using the ILogger interface I use the ILog Interface, mostly because I wanted to use LogDebug, LogInfo, ... for comfort. Doing it with the given line, I expect it to work similarily to the example, namely

private
readonly static Type declaringType =3D typeof(Log4NetLogger);
_logger.Log(declaringType, log4net.Core.Level.Info, message, e);


Am I wrong to expect it to work in the same way?




Ron Grabowski <ron= grabowski@yahoo.com>

03.06.2012 01:11
Bitte antworten an "Log4NET User" <log4net-user@logging.apache.org>

An
Log4NET User <log4net= -user@logging.apache.org>
Kopie
Thema
Re: ILog Wrapping







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:


http://svn.apache.org/viewvc/ibatis/cs/ibatisnet-1/trunk/src/= IBatisNet.Common.Logging.Log4Net/

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



From: Martin Milan <Martin.Mila= n@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?
<= font size=3D3 color=3D#004080 face=3D"Roman">
 
Just an idea…

 
 
From:
Andreas HOELZLWIMMER [
mailto:andreas.hoe= lzlwimmer@racon.at]
Sent:
01 June 2012 08:36
To:
log4net-user@logging.apache.org
Subject:
ILog Wrapping

 
Hi,
I need to switch our logger to Log4Net in our application. I need to implem= ent our personal logging interface, which means I need to wrap the Logger. The logger requires to display method name and namespace. With the "us= ual" way it always shows the method and namespace of the wrapper, not the method called. The option found on stackoverflow (
http://stackove= rflow.com/questions/157232/how-to-log-methodname-when-wrapping-log4net<= /font>) 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,
Andreas


Der Austausch von Nachrichten mit o.a. Absender via e-mail dient ausschlie= =DFlich Informationszwecken. Rechtsgesch=E4ftliche Erkl=E4rungen d=FCrfen =FCber di= eses 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 communica= tions.

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







Der Austausch von Nachrichten mit o.a. Absender via e-mail dient ausschlie= =DFlich Informationszwecken. Rechtsgesch=E4ftliche Erkl=E4rungen d=FCrfen =FCber di= eses 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 communica= tions.





Der Austausch von Nachrichten mit o.a. Absender via e-mail dient aussch= lie=DFlich Informationszwecken. Rechtsgesch=E4ftliche Erkl=E4rungen d=FCrfe= n =FCber dieses Medium nicht ausgetauscht werden.

Correspondence with a.m. sender via e-mail is only for information purp= oses. This medium is not to be used for the exchange of legally-binding com= munications.

--=_alternative 004EA7F4C1257A13_=--