Return-Path: Delivered-To: apmail-logging-log4net-user-archive@www.apache.org Received: (qmail 51865 invoked from network); 24 Oct 2007 00:31:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 24 Oct 2007 00:31:49 -0000 Received: (qmail 64727 invoked by uid 500); 24 Oct 2007 00:31:36 -0000 Delivered-To: apmail-logging-log4net-user-archive@logging.apache.org Received: (qmail 64694 invoked by uid 500); 24 Oct 2007 00:31: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 64683 invoked by uid 99); 24 Oct 2007 00:31:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Oct 2007 17:31:36 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of dfiala@celadonlabs.com designates 63.134.198.9 as permitted sender) Received: from [63.134.198.9] (HELO mail.celadonlabs.com) (63.134.198.9) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Oct 2007 00:31:36 +0000 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary=----_SmarterMail_NextPart_7648046606225335 Date: Tue, 23 Oct 2007 17:30:38 -0700 Subject: RE: Config log4net in n-tiear application Framework 2.0! From: "Dean Fiala" Reply-To: dfiala@celadonlabs.com To: CC: Message-ID: <27756a950ee541eb82a58848dbcb6019@celadonlabs.com> X-Virus-Checked: Checked by ClamAV on apache.org This is a multi-part message in MIME format. ------_SmarterMail_NextPart_7648046606225335 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable You are correct, there is no need to set the attribute in each assembly. T= he top level assembly handles the configuration -- everyone else goes along= for the ride. We have a number of library assemblies that get used in dif= ferent applications (web app, web service, service), so we didn't want to h= ard code any configuration information at the library level. Fortunately, t= here is no need to. A reference to log4net and a call to LogManager.GetLog= ger() in the library classes is all that is needed. =0D=0A=0D=0ARegards,= =0D=0A=0D=0ADean Fiala=0D=0A=0D=0A----------------------------------------= =0D=0AReturn-Path: Tue Oct 23 16:28:52 2007=0D=0AReceived: from hermes.apache.o= rg [140.211.11.2] by mail.celadonlabs.com with SMTP;=0D=0A Tue, 23 Oct 2007= 16:28:52 -0700=0D=0AReceived: (qmail 13007 invoked by uid 500); 23 Oct 200= 7 23:28:36 -0000=0D=0AReceived: (qmail 12989 invoked by uid 99); 23 Oct 200= 7 23:28:36 -0000=0D=0AReceived: from athena.apache.org (HELO athena.apache.= org) (140.211.11.136)=0D=0A by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 2= 3 Oct 2007 16:28:36 -0700=0D=0AReceived: from [216.150.133.132] (HELO ex2.t= echsoftwareinc.com) (216.150.133.132)=0D=0A by apache.org (qpsmtpd/0.29) wi= th ESMTP; Tue, 23 Oct 2007 23:28:27 +0000=0D=0AMailing-List: contact log4ne= t-user-help@logging.apache.org; run by ezmlm=0D=0APrecedence: bulk=0D=0Alis= t-help: =0D=0Alist-unsubscribe= : =0D=0AList-Post: =0D=0AReply-To: "Log4NET User" =0D=0AList-Id: = =0D=0ADelivered-To: mailing list log4net-user@logging.apache.org=0D=0AX-ASF= -Spam-Status: No, hits=3D2.0 required=3D10.0=0D=0A tests=3DHTML_MESSAGE,SPF= _PASS=0D=0AX-Spam-Check-By: apache.org=0D=0AReceived-SPF: pass (athena.apac= he.org: domain of WaldenL@techsoftinc.com designates 216.150.133.132 as per= mitted sender)=0D=0AContent-class: urn:content-classes:message=0D=0AMIME-Ve= rsion: 1.0=0D=0AContent-Type: multipart/alternative;=0D=0A boundary=3D"----= _=3D_NextPart_001_01C815CC.5C0026CC"=0D=0ASubject: RE: Config log4net in n-= tiear application Framework 2.0!=0D=0AX-MimeOLE: Produced By Microsoft Exch= ange V6.5=0D=0ADate: Tue, 23 Oct 2007 19:28:03 -0400=0D=0AMessage-ID: <43A1= 0173A6B4F54BACFACFB39EBD47550251E3@ex2.techsoftwareinc.com>=0D=0AX-MS-Has-A= ttach: =0D=0AX-MS-TNEF-Correlator: =0D=0AThread-Topic: Config log4net in n-= tiear application Framework 2.0!=0D=0AThread-Index: AcgVuTHX95aG9+DDSR6aalJ= Vu5TSTwAAEyHAAASeE6A=3D=0D=0AReferences: <006701c815b9$3201f020$0428020a@IB= M81135397> = =0D=0AFrom: "Walden H. Leverich" =0D=0ATo: "Log4NE= T User" =0D=0AX-Virus-Checked: Checked by = ClamAV on apache.org=0D=0AX-SmarterMail-Spam: SPF_Pass=0D=0AX-Rcpt-To: =0D=0A=0D=0A > For each project, reference the log4= net dll and put the following line in the assemblyInfo file: I agree with= referencing the log4net.dll, but I don't think you need to put the [assemb= ly.] attribute in. At least not if the top-level application (asp.net) does= the configure through code. We don't use the attribute at all and we get l= ogging from all our levels. Our ASP.Net code does though do this in global.= sasx: protected void Application_Start(object sender, EventArgs e= ) { string configFile =3D Server.MapPath(ConfigurationM= anager.AppSettings["log4net-config-file"]); log4net.Config.XmlC= onfigurator.ConfigureAndWatch(new System.IO.FileInfo(configFile)); = log =3D log4net.LogManager.GetLogger( = System.Reflection.MethodBase.GetCurrentMet= hod().DeclaringType); log.InfoFormat("Watching '{0}'", config= File); } -Walden -- Walden H Leverich III=0D=0A Tech Software= =0D=0A (516) 627-3800 x3051 WaldenL@TechSoftInc.com=0D=0A http://www.TechS= oftInc.com=0D=0A=0D=0A Quiquid latine dictum sit altum viditur.=0D=0A (What= ever is said in Latin seems profound.) From: Dave McEwan [mailto:dmcewan@= harmonyis.com] =0D=0A Sent: Tuesday, October 23, 2007 5:18 PM=0D=0A To: Log= 4NET User=0D=0A Subject: RE: Config log4net in n-tiear application Framewor= k 2.0! For each project, reference the log4net dll and put the follow= ing line in the assemblyInfo file: [assembly: log4net.Config.= XmlConfigurator( ConfigFile=3D"log4net.config",Watch=3Dtrue )] Now at the= class level for each class add the following line to create an instance of= the logger: private static readonly ILog log =3D LogManager.= GetLogger( MethodBase.GetCurrentMethod().DeclaringType); Now you can = make calls like so from your methods: log.Error(ex.Message.To= String(), ex); Hope that helps Dave =0D=0A-------------------------= ---------------=0D=0A From: Erlis Vidal [mailto:Evidal@affiliated.ca] =0D= =0A Sent: Tuesday, October 23, 2007 5:11 PM=0D=0A To: log4net-user@logging.= apache.org=0D=0A Subject: Config log4net in n-tiear application Framework 2= .0! Hi everyone! I want to configure log4net in order to use the same = configuration file (with the watch option active) in my n-tier application!= I have the following structure in my solution: Website (as a web appli= cation project) Business (as a class library project) Data (as a class libr= ary project) Test (as a class library project) I want to be able to log m= essages in any of those layers using the same log4net configuration file...= Can you provide any suggestion for the right configuration? Regards, E= rlis =0D=0A ------_SmarterMail_NextPart_7648046606225335 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable You are correct, there is no need to set the attribute in ea= ch assembly.  The top level assembly handles the configuration -- ever= yone else goes along for the ride.  We have a number of library assemb= lies that get used in different applications (web app, web service, service= ), so we didn't want to hard code any configuration information at the libr= ary level. Fortunately, there is no need to.  A reference to log4net a= nd a call to LogManager.GetLogger() in the library classes is all that is n= eeded. 

Regards,

Dean Fiala



Return-Path: <log4net-user-return-4= 064-dfiala=3Dceladonlabs.com@logging.apache.org> Tue Oct 23 16:28:52 200= 7
Received: from hermes.apache.org [140.211.11.2] by mail.celadonlabs.= com with SMTP;
Tue, 23 Oct 2007 16:28:52 -0700
Received: (qmail = 13007 invoked by uid 500); 23 Oct 2007 23:28:36 -0000
Received: (qmail= 12989 invoked by uid 99); 23 Oct 2007 23:28:36 -0000
Received: from a= thena.apache.org (HELO athena.apache.org) (140.211.11.136)
by apache.= org (qpsmtpd/0.29) with ESMTP; Tue, 23 Oct 2007 16:28:36 -0700
Receive= d: from [216.150.133.132] (HELO ex2.techsoftwareinc.com) (216.150.133.132)<= br /> by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Oct 2007 23:28:27 +0= 000
Mailing-List: contact log4net-user-help@logging.apache.org; run by= ezmlm
Precedence: bulk
list-help: <mailto:log4net-user-help@l= ogging.apache.org>
list-unsubscribe: <mailto:log4net-user-unsubs= cribe@logging.apache.org>
List-Post: <mailto:log4net-user@loggin= g.apache.org>
Reply-To: "Log4NET User" <log4net-user@logging.apa= che.org>
List-Id: <log4net-user.logging.apache.org>
Deli= vered-To: mailing list log4net-user@logging.apache.org
X-ASF-Spam-Stat= us: No, hits=3D2.0 required=3D10.0
tests=3DHTML_MESSAGE,SPF_PASS
X-Spam-Check-By: apache.org
Received-SPF: pass (athena.apache.org: do= main of WaldenL@techsoftinc.com designates 216.150.133.132 as permitted sen= der)
Content-class: urn:content-classes:message
MIME-Version: 1.0=
Content-Type: multipart/alternative;
boundary=3D"----_=3D_NextP= art_001_01C815CC.5C0026CC"
Subject: RE: Config log4net in n-tiear appl= ication Framework 2.0!
X-MimeOLE: Produced By Microsoft Exchange V6.5<= br />Date: Tue, 23 Oct 2007 19:28:03 -0400
Message-ID: <43A10173A6B= 4F54BACFACFB39EBD47550251E3@ex2.techsoftwareinc.com>
X-MS-Has-Attac= h:
X-MS-TNEF-Correlator:
Thread-Topic: Config log4net in n-tiea= r application Framework 2.0!
Thread-Index: AcgVuTHX95aG9+DDSR6aalJVu5T= STwAAEyHAAASeE6A=3D
References: <006701c815b9$3201f020$0428020a@IBM= 81135397> <B40107648DAD6540AA509289008D6E27029E33@hisexch03.harmonyis= .org>
From: "Walden H. Leverich" <WaldenL@TechSoftInc.com>To: "Log4NET User" <log4net-user@logging.apache.org>
X-Virus-= Checked: Checked by ClamAV on apache.org
X-SmarterMail-Spam: SPF_Pass<= br />X-Rcpt-To: <dfiala@celadonlabs.com>