logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dean Fiala" <dfi...@celadonlabs.com>
Subject RE: Config log4net in n-tiear application Framework 2.0!
Date Wed, 24 Oct 2007 00:30:38 GMT
You are correct, there is no need to set the attribute in each assembly.  The top level assembly
handles the configuration -- everyone else goes along for the ride.  We have a number of library
assemblies that get used in different applications (web app, web service, service), so we
didn't want to hard code any configuration information at the library level. Fortunately,
there is no need to.  A reference to log4net and a call to LogManager.GetLogger() in the library
classes is all that is needed.  

Regards,

Dean Fiala

----------------------------------------
Return-Path: <log4net-user-return-4064-dfiala=celadonlabs.com@logging.apache.org> Tue
Oct 23 16:28:52 2007
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 athena.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
Received: from [216.150.133.132] (HELO ex2.techsoftwareinc.com) (216.150.133.132)
 by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Oct 2007 23:28:27 +0000
Mailing-List: contact log4net-user-help@logging.apache.org; run by ezmlm
Precedence: bulk
list-help: <mailto:log4net-user-help@logging.apache.org>
list-unsubscribe: <mailto:log4net-user-unsubscribe@logging.apache.org>
List-Post: <mailto:log4net-user@logging.apache.org>
Reply-To: "Log4NET User" <log4net-user@logging.apache.org>
List-Id: <log4net-user.logging.apache.org>
Delivered-To: mailing list log4net-user@logging.apache.org
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 WaldenL@techsoftinc.com designates 216.150.133.132
as permitted sender)
Content-class: urn:content-classes:message
MIME-Version: 1.0
Content-Type: multipart/alternative;
 boundary="----_=_NextPart_001_01C815CC.5C0026CC"
Subject: RE: Config log4net in n-tiear application Framework 2.0!
X-MimeOLE: Produced By Microsoft Exchange V6.5
Date: Tue, 23 Oct 2007 19:28:03 -0400
Message-ID: <43A10173A6B4F54BACFACFB39EBD47550251E3@ex2.techsoftwareinc.com>
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
Thread-Topic: Config log4net in n-tiear application Framework 2.0!
Thread-Index: AcgVuTHX95aG9+DDSR6aalJVu5TSTwAAEyHAAASeE6A=
References: <006701c815b9$3201f020$0428020a@IBM81135397> <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
X-Rcpt-To: <dfiala@celadonlabs.com> 

    > For each project, reference the log4net 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 [assembly.]
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 logging 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 = Server.MapPath(ConfigurationManager.AppSettings["log4net-config-file"]);
            log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(configFile));
              log = log4net.LogManager.GetLogger(                                        
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);  
            log.InfoFormat("Watching '{0}'", configFile);         }   -Walden    --  Walden
H Leverich III
 Tech Software
 (516) 627-3800 x3051  WaldenL@TechSoftInc.com
 http://www.TechSoftInc.com

 Quiquid latine dictum sit altum viditur.
 (Whatever is said in Latin seems profound.)   From: Dave McEwan [mailto:dmcewan@harmonyis.com]

 Sent: Tuesday, October 23, 2007 5:18 PM
 To: Log4NET User
 Subject: RE: Config log4net in n-tiear application Framework 2.0!       For each project,
reference the log4net dll and put the following line in the assemblyInfo file:           
   [assembly: log4net.Config.XmlConfigurator( ConfigFile="log4net.config",Watch=true )]  
Now at the class level for each class add the following line to create an instance of the
logger:               private static readonly ILog log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType);
      Now you can make calls like so from your methods:               log.Error(ex.Message.ToString(),
ex);     Hope that helps Dave     
----------------------------------------
  From: Erlis Vidal [mailto:Evidal@affiliated.ca] 
 Sent: Tuesday, October 23, 2007 5:11 PM
 To: log4net-user@logging.apache.org
 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 application project) Business (as a class library project) Data (as a class library project)
Test (as a class library project)   I want to be able to log messages in any of those layers
using the same log4net configuration file...  Can you provide any suggestion for the right
configuration?    Regards, Erlis 


Mime
View raw message