Return-Path: Delivered-To: apmail-logging-log4net-user-archive@www.apache.org Received: (qmail 156 invoked from network); 2 Sep 2009 15:26:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Sep 2009 15:26:03 -0000 Received: (qmail 41259 invoked by uid 500); 2 Sep 2009 15:26:03 -0000 Delivered-To: apmail-logging-log4net-user-archive@logging.apache.org Received: (qmail 41225 invoked by uid 500); 2 Sep 2009 15:26:03 -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 41216 invoked by uid 99); 2 Sep 2009 15:26:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Sep 2009 15:26:03 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of mike.schall@gmail.com designates 209.85.221.173 as permitted sender) Received: from [209.85.221.173] (HELO mail-qy0-f173.google.com) (209.85.221.173) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Sep 2009 15:25:53 +0000 Received: by qyk3 with SMTP id 3so360552qyk.4 for ; Wed, 02 Sep 2009 08:25:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=Or0r3pzyGYuPhX5+FZnkQV8cTtIA8MlAXOEc1q2q1wQ=; b=YzrDI1gkDHX+Cy+P5DMOeL//mJTZOAguXxmJUeV16K64tQFmXfeJRYoAe6RyxhWfS7 NMuFjjuz5IA6qX/03jaAzwGhZPiZcus/kq+5noeOdmi4IlbtfY5UdMMCqm5uEkLi2vlM XzJ3SXtaDUNTnsAVzUsv0Gq18TslAdQmEAFiA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=KaclCS8xG3qWFe76OEo2YR0LMs+fXlbk+xL21UpzTkLzJgY0J6d6JaUOPEjo+JKXWw HBMyqqaN915vK7grh+suMW4+k7nNxTxnNP0TtEL25g9Auu882mrT+hieYBTeoJsa8hf7 Vyy6x3maGpZ+sJOS4/x42Zg0R0/KXn6ALlEBw= MIME-Version: 1.0 Received: by 10.224.52.221 with SMTP id j29mr5344781qag.347.1251905131902; Wed, 02 Sep 2009 08:25:31 -0700 (PDT) In-Reply-To: <25258147.post@talk.nabble.com> References: <24807634.post@talk.nabble.com> <25253548.post@talk.nabble.com> <5f9068320909020639j17cdb6eage9732d6d8825126e@mail.gmail.com> <25258147.post@talk.nabble.com> Date: Wed, 2 Sep 2009 10:25:31 -0500 Message-ID: <5f9068320909020825r9cc4c98mc12be8447d29b286@mail.gmail.com> Subject: Re: Log in more than 1 log destination for different assemblies. From: Michael Schall To: Log4NET User Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Instead of using the GlobalContext.Properties to define where your logs are coming from I would define a Shared/Static logger per class based on the fully qualified class name allowing you to use the logger hierarchy as defined here http://logging.apache.org/log4net/release/manual/introduction.html The FAQ has a section too... http://logging.apache.org/log4net/release/faq.html#Implementing%20Logging This way you can turn off specific loggers, direct them to different appenders, ... Mike On Wed, Sep 2, 2009 at 9:01 AM, mattyboy wrote= : > > Thanks for the replying. > > When I say mutliple assemblies I have a GUI app. and it uses log4net to l= og > to a file let's say 'C:\Claymore.log'. > > I have developed several .dll files which I call from within the GUI app.= =A0I > want the code within the .dll files to also log to 'C:\Calymore.log'. > > I've actually just managed to get it working but I'm not using locking an= d > wonder whether I should be or not for this scenario. =A0As far as I'm awa= re > everything will run in the same process and should be fine without > locking......? > > Here's what I've done: > > In both the GUI front-end and each .dll I have added the following entry = to > the AssemblyInfo.vb (yes, I'm using vb.net!) file > > log4net.Config.XMLConfigurator(ConfigFile:=3D"Claymore.exe.log4net", > Watch:=3DTrue)> > > In GUI Front-End Assembly ONLY I've added 'Claymore.exe.log4net' file. > > Then in GUI Front-End class: > > Public Class frmDashboard > =A0 =A0Public Shared logger As log4net.ILog > > =A0 =A0Private Sub frmDashboard_Load(ByVal sender As Object, ByVal e As > System.EventArgs) Handles Me.Load > =A0 =A0 =A0 =A0log4net.GlobalContext.Properties("AssemblyName") =3D > Assembly.GetExecutingAssembly.GetName.Name() > =A0 =A0 =A0 =A0logger =3D log4net.LogManager.GetLogger("ClaymoreLogger") > =A0 =A0 =A0 =A0logger.Info("Dashboard_Load() - Start") > =A0 =A0 =A0 =A0logger.Debug("Dashboard_Load() - Finish") > =A0 =A0 =A0 =A0Dim clsGUI As New ClaymoreGUI.clsDashboard() > =A0 =A0End Sub > End Class > > In my ClaymoreGUI.dll: > > Public Class clsDashboard > =A0 =A0Public Shared logger As log4net.ILog > > =A0 =A0Public Sub New() > =A0 =A0 =A0 =A0log4net.GlobalContext.Properties("AssemblyName") =3D > Assembly.GetExecutingAssembly.GetName.Name() > =A0 =A0 =A0 =A0logger =3D log4net.LogManager.GetLogger("ClaymoreLogger") > =A0 =A0 =A0 =A0logger.Info("New() - Start") > =A0 =A0 =A0 =A0logger.Debug("New() - Finish") > =A0 =A0End Sub > End Class > > Seems to work well :-) > > > > Michael Schall wrote: >> >> When you say multiple assemblies, I assume you mean multiple >> processes? =A0Logging this way is not suggested as for each log message >> you have to reopen the file. =A0If you have really light logging, it >> would probably be ok... >> >> Look at the LockingModel: >> http://logging.apache.org/log4net/release/sdk/log4net.Appender.FileAppen= der.LockingModel.html >> >> From http://logging.apache.org/log4net/release/config-examples.html: >> >> This example shows how to configure the appender to use the minimal >> locking model that allows multiple processes to write to the same >> file. >> >> >> =A0 =A0 >> =A0 =A0 >> =A0 =A0 >> =A0 =A0 >> =A0 =A0 =A0 =A0 > [%property{NDC}] - %message%newline" /> >> =A0 =A0 >> >> >> On Wed, Sep 2, 2009 at 3:28 AM, mattyboy >> wrote: >>> >>> Hi Christian, >>> >>> I'm actually looking to achieve the opposite, I want to know if it's >>> possible to get several assemblies to log to the SAME log file. =A0Have= you >>> managed to achieve this? =A0If so, do you have any example code/configs >>> etc.? >>> >>> Many Thanks >>> >>> >>> cristianmad wrote: >>>> >>>> Hi, >>>> >>>> I am new to log4net and just starting reading some documentation about >>>> it. >>>> We need to see if it would be a suitable logging solution for our >>>> applications. >>>> Our product (like most of them) uses a number of assemblies. I was >>>> wondering if it would be possible for each assembly to log in its own >>>> log >>>> file (or any other destination) even if they are loaded in the same >>>> application domain. >>>> For example consider we have the following assemblies: A.dll and B.dll= . >>>> Is >>>> it possible for the two assemblies to log in their own log files even = if >>>> they are loaded in the same application domain? >>>> If yes, could you please give me a very simple example? >>>> >>>> >>>> Thank you, >>>> Cristian >>>> >>> >>> -- >>> View this message in context: >>> http://www.nabble.com/Log-in-more-than-1-log-destination-for-different-= assemblies.-tp24807634p25253548.html >>> Sent from the Log4net - Users mailing list archive at Nabble.com. >>> >>> >> >> > :-):-):-) > -- > View this message in context: http://www.nabble.com/Log-in-more-than-1-lo= g-destination-for-different-assemblies.-tp24807634p25258147.html > Sent from the Log4net - Users mailing list archive at Nabble.com. > >