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 40D2117758 for ; Sun, 5 Oct 2014 04:29:58 +0000 (UTC) Received: (qmail 43804 invoked by uid 500); 5 Oct 2014 04:29:58 -0000 Delivered-To: apmail-logging-log4net-user-archive@logging.apache.org Received: (qmail 43762 invoked by uid 500); 5 Oct 2014 04:29:57 -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 43752 invoked by uid 99); 5 Oct 2014 04:29:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Oct 2014 04:29:57 +0000 X-ASF-Spam-Status: No, hits=-0.1 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_MED,SPF_PASS,T_REMOTE_IMAGE X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of rmashal@magicsoftware.com designates 207.126.144.125 as permitted sender) Received: from [207.126.144.125] (HELO eu1sys200aog108.obsmtp.com) (207.126.144.125) by apache.org (qpsmtpd/0.29) with SMTP; Sun, 05 Oct 2014 04:29:31 +0000 Received: from mail-qc0-f177.google.com ([209.85.216.177]) (using TLSv1) by eu1sys200aob108.postini.com ([207.126.147.11]) with SMTP ID DSNKVDDJKonSXVemMmVvm8pbiQB9yTi4nnxc@postini.com; Sun, 05 Oct 2014 04:29:31 UTC Received: by mail-qc0-f177.google.com with SMTP id c9so2695273qcz.36 for ; Sat, 04 Oct 2014 21:29:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=magicsoftware.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=S46HLUobo+gCyoc+NWM7Qp4Kq/MvBjhWkpGZDNe4P8Y=; b=fENSKiKwdjr3cDsqHX8h/xqMslZ2h6GRfrrNxWw/kfC+Dil3nM8h+qa2qY1Pzc/QbM i1m6/dZMf9aRufbQr+NtwntKhd5JPdWAJtZlR0NOzHtV3USlrefufKZEPDKApaySeSUy gJhJHSOmyJcgcvrgmjPcWzcg+lhWRHdY4EUL0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=S46HLUobo+gCyoc+NWM7Qp4Kq/MvBjhWkpGZDNe4P8Y=; b=mm02XVxPRcSqtFIxeUnPtBlZjXJbmyppmsoYPxJhhCHl3EgMpYM+YdnIKtOFVGiuQ+ 6+x47O6abKITuIPxrl7/vXc0XXMvA4aajhn5R7S96U1GJiqLqtv0oM+IZ7PgNtmIOmRi hc9wEKUOqgR8SY71eUQ/Lv2gcjYi/PuEgTJuEZG5xImAbjRYUDZCmfmoCw3EYDfY6qC3 AVtH84OyYwkg39K/0EzIhsWXmZZtJBbnCyP0qSGiZf0H0XUFnzw4If3WZUqeNxR49Uzy tUHadbMH+s7us66cwPP1sVDZ6ZMV+OrpqsHCz3JCmaq33JrMagDxDAiDCDpnPh6r1MAH tz8Q== X-Gm-Message-State: ALoCoQnsSuK/aaPog4iMnlkCVY25v+jsB/OwR71sxh7g/ndemOh2ytOJiGyVEQwPLdrSj3PqPxN23VFDyL9DoED2TmjNpucqF8Thj14EnJU/g3sBIbuIlwr5G+mrZwKj0xpf4c6OWF49EUljCQnRdqvTRmUYPkWWbv6efWUGeja+LXXA6Og3tBc= X-Received: by 10.140.20.3 with SMTP id 3mr17941707qgi.33.1412483369796; Sat, 04 Oct 2014 21:29:29 -0700 (PDT) X-Received: by 10.140.20.3 with SMTP id 3mr17941686qgi.33.1412483369548; Sat, 04 Oct 2014 21:29:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.216.7 with HTTP; Sat, 4 Oct 2014 21:29:09 -0700 (PDT) In-Reply-To: <67D108EDFAD3C148A593E6ED7DCB4BBDFF0E4BBD@RADCONWIN2K8PDC.radcon.local> References: <67D108EDFAD3C148A593E6ED7DCB4BBDFF0E4BBD@RADCONWIN2K8PDC.radcon.local> From: Ronen Mashal Date: Sun, 5 Oct 2014 07:29:09 +0300 Message-ID: Subject: Re: Two logs have the same appenders To: Log4NET User Content-Type: multipart/alternative; boundary=001a11c137b87e58fa0504a569f6 X-Virus-Checked: Checked by ClamAV on apache.org --001a11c137b87e58fa0504a569f6 Content-Type: text/plain; charset=UTF-8 Hello Rob, If you want to write the same messages to two separate files you should do the following: 1) Define two file appenders in the configuration file, each writing to a different file. 2) Create a logger (or specify in the "root" logger) that it uses both file appenders, something like this: Now, if you want to direct different messages to different log files, you would have to define another logger and use that logger in the code. Here's an example: then in the code: ILog logger1 = log4net.LogManager.GetLogger(typeof(classname)); ILog logger2 = log4net.LogManager.GetLogger(typeof(classname).FullName + ".sepcial"); Now you'd be able to write different message to different files. There are other options that involve using filters if you want, for example, to write all messages to one log but only a subset to another. Ronen Mashal. On Fri, Oct 3, 2014 at 11:45 PM, Rob Richardson wrote: > I want to get two independent sets of appender objects from the same > configuration file, so that I can use different file names in a > FileAppender, for example. But the standard way of getting appender > objects is to use the LogManager object, which is static. Since there's > only one LogManager, it will always return the same set of appender > objects. So, I get one ILog object, get its FileAppender object, set its > file name, and write a message, and it appears in the expected file. Then, > I get another ILog object, get the FileAppender object, set its file name > to some other file, and write a message, and that message appears in the > second file. Finally, I go back to the first file appender, write another > message, and it appears in the second appenders file. > > Is there a way to copy a FileAppender object, or to get a new object for > the same appender name out of the LogManager? > > Thanks very much! > > RobR, who will probably have to just build the logger programmatically > instead of using a configuration file > -- [image: email_sig] *Ronen Mashal* *Software Engineer *| Magic Software Enterprises Ltd. Tel. +972-3-5389215 | Fax. +972-3-5389333 rmashal@magicsoftware.com | www.magicsoftware.com | [image: Facebook] [image: Twitter] [image: Linkedin] [image: YouTube] [image: Google+] [image: Magic Software Blog] DISCLAIMER. Information in this message and its attachments may be privileged or confidential. It is for the exclusive use of the intended recipient(s). If you are not one of the intended recipients, you are hereby informed that any use, disclosure, distribution, and/or copying of this information is strictly prohibited. If you receive this message in error, please notify the sender immediately and delete all copies of this message. We recommend that you scan your incoming Emails. We cannot accept responsibility for any transmitted viruses. --001a11c137b87e58fa0504a569f6 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hello Rob,

If you want to wr= ite the same messages to two separate files you should do the following:
1) Define two file appenders in the configuration file, each writin= g to a different file.
2) Create a logger (or specify in the &quo= t;root" logger) that it uses both file appenders, something like this:=
<logger name=3D"a.b.c.classname">
=C2= =A0 =C2=A0 <appender-ref ref=3D"filelogger1"/>
= =C2=A0 =C2=A0 <appender-ref ref=3D"filelogger2"/>
</logger>

Now, if you want to direct differ= ent messages to different log files, you would have to define another logge= r and use that logger in the code. Here's an example:

<logger name=3D"a.b.c.classname">
=C2=A0 = =C2=A0 =C2=A0<appender-ref ref=3D"filelogger1"/>
= </logger>

<logger name=3D"a.b.c.clas= sname.special">
=C2=A0 =C2=A0 =C2=A0<appender-ref ref= =3D"filelogger2"/>
</logger>

then in the code:
ILog logger1 =3D log4net.LogManager.Get= Logger(typeof(classname));
ILog logger2 =3D log4net.LogManager.Ge= tLogger(typeof(classname).FullName + ".sepcial");

<= /div>
Now you'd be able to write different message to different fil= es.

There are other options that involve using fil= ters if you want, for example, to write all messages to one log but only a = subset to another.

Ronen Mashal.





--

=C2=A0

3D"email_sig"
Ronen Mashal
<= br>Software Engineer=C2=A0|=C2=A0= Magic Software Enterprises Ltd.

Tel.=C2=A0+972-3-5389215 = =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A0 =C2=A0 Fax.=C2=A0+972-3-5389333
rmashal@magicsoftwa= re.com=C2=A0|=C2=A0www.magicsoftwar= e.com=C2=A0|=C2=A03D"Facebook"3D"Twitter"3D"Linkedin"3D"YouTube"3D"Google+"<= /span>3D"Magic

=C2=A0



DISCLAIMER. Informatio= n in this message and its attachments may be privileged or confidential. It= is for the exclusive use of the intended recipient(s).=C2=A0
If you are= not one of the intended recipients, you are hereby informed that any use, = disclosure, distribution, and/or copying of this information is strictly pr= ohibited.=C2=A0
If you receive this message in error, please notify the = sender immediately and delete all copies of this message. We recommend that= you scan your incoming Emails.=C2=A0
We cannot accept responsibility fo= r any transmitted viruses.

--001a11c137b87e58fa0504a569f6--