Return-Path: Delivered-To: apmail-logging-log4net-user-archive@www.apache.org Received: (qmail 76911 invoked from network); 3 Sep 2010 10:21:16 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 3 Sep 2010 10:21:16 -0000 Received: (qmail 51639 invoked by uid 500); 3 Sep 2010 10:21:16 -0000 Delivered-To: apmail-logging-log4net-user-archive@logging.apache.org Received: (qmail 51262 invoked by uid 500); 3 Sep 2010 10:21:13 -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 51254 invoked by uid 99); 3 Sep 2010 10:21:12 -0000 Received: from Unknown (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Sep 2010 10:21:12 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [217.112.162.197] (HELO main.hasam.cz) (217.112.162.197) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Sep 2010 10:20:49 +0000 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable Subject: RE: how often to call XmlConfigurator.Configure X-MimeOLE: Produced By Microsoft Exchange V6.5 Date: Fri, 3 Sep 2010 12:20:27 +0200 Message-ID: <0794C17B67A72245B24284103E4959D2315DBA@main.hasam.cz> In-Reply-To: <755840.76737.qm@web56301.mail.re3.yahoo.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: how often to call XmlConfigurator.Configure Thread-Index: ActKwp5oFtUkIKYBQqWpzNbLqZLObgAjk2Sw References: <755840.76737.qm@web56301.mail.re3.yahoo.com> From: "Radovan Raszka" To: "Log4NET User" X-Virus-Checked: Checked by ClamAV on apache.org Log4net system should be configured only once int the "starting" class = of your application (first class used in the application) or any other = class but before first logging attempt.. If you configure more times, only the last configuration is used. But you can use log4net in way that every class uses its own appender. RR -----P=F9vodn=ED zpr=E1va----- Od: T Dog [mailto:acedog032000@yahoo.com]=20 Odesl=E1no: 2. z=E1=F8=ED 2010 19:16 Komu: log4net-user@logging.apache.org P=F8edm=ECt: how often to call XmlConfigurator.Configure I have a simple C# .net 2.0 program where a console application calls = into a Caller class which then calls into a Callee class.=A0 I want to = have separate log4net configurations for the console application, for = the Caller dll, and for the Callee dll.=A0 Each of the 3 should write to = its own rolling log file appender.=A0=A0 I call = XmlConfigurator.Configure in the constructor of the Caller, the Callee, = and in the Main method of the console application.=A0 It ends up that = the console application starts writing to its own log file, but then = ends up writing into the innermost, the Callee's, log file.=A0 I can get = the console application to write back to its own log file if I call = XmlConfigurator.Configure again before I want to write to the console = app's log file.=A0 Is that necessary or did I configure this = incorrectly?=A0 I want to be able to have varying levels of log4net = capability and verbosity at each of the 3 levels. Here's the guts of the console application: =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = log4net.Config.XmlConfigurator.Configure(new = System.IO.FileInfo(Assembly.GetExecutingAssembly().Location + = ".config")); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 string message =3D "message from main = generated at : " + DateTime.Now.ToLongTimeString(); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 _log.Error("error" + message); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 _log.Warn("warn" + message); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 _log.Info("info" + message); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 _log.Debug("debug" + message); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=20 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Caller caller =3D new Caller(); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 caller.MethodOne(); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // if the following line is commented = out, then the output goes into the Callee's log file (which was the last = class to call XmlConfigurator.Configure), not into the console = application's log file =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = log4net.Config.XmlConfigurator.Configure(new = System.IO.FileInfo(Assembly.GetExecutingAssembly().Location + = ".config")); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 message =3D "message from main generated = at : " + DateTime.Now.ToLongTimeString(); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 _log.Error("error" + message); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 _log.Warn("warn" + message); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 _log.Info("info" + message); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 _log.Debug("debug" + message); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Caller caller2 =3D new Caller(); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 caller2.MethodOne(); =20