RE: How to add an Appender to Log4net programmatically at runtime ?

"Vincent Daron" <[email protected]> Thu, 22 Jan 2004 17:38:54 +0100
Newsgroups gmane.comp.windows.dotnet.log4net.user
Message-ID <[email protected]>
This is a multi-part message in MIME format.

------=_NextPart_000_002D_01C3E10E.9B4E2F50
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

But when a new Logger is created, it receive some appenders, I just like to
be include in this list ..

 

I'll look into the code.

 

Thanks

  _____  

From: Denis, Rich [mailto:[email protected]] 
Sent: jeudi 22 janvier 2004 17:34
To: 'Vincent Daron'
Subject: RE: [Log4net-users] How to add an Appender to Log4net
programmatically at runtime ?

 

You make perfect sense.  Unfortunately I don't think that you can do what
you are trying to do.  You are only modifying the loggers that are known at
the time you run your code.  The only way I could think that you would get
it to work is to somehow programmatically set the configuration file, but I
am not sure how you would do this.

 

  

Rich Denis
perotsystemsT

(972) 577-5869 Wk

 

  _____  

From: Vincent Daron [mailto:[email protected]] 
Sent: Thursday, January 22, 2004 10:23 AM
To: Denis, Rich
Subject: RE: [Log4net-users] How to add an Appender to Log4net
programmatically at runtime ?

 

Thanks, but it did'nt solve my problem .

 

I'll try to be clearer,

 

I've created an Appender, and I want to "Attach" it on all the Loggers at
runtime. I want to Add it to the Appender specified in configuration file.
I've found the following code since my first post :

 

foreach(ILoggerRepository tmp in LoggerManager.GetAllRepositories())

{

   foreach(Logger tmp2 in tmp.GetCurrentLoggers())

   {

      tmp2.AddAppender(theAppender);

   }

}

 

The problem with this approach is that all the assemblies loaded after this
code do not log in My Appender (but they log in the appenders specified in
configuration). If I load these assemblies before (by creating a dummy
object for example), it run fine, and MyAppender receive every LoggingEvent.
I can't do it for all the external assemblies of course ..

 

Thanks for answer

 

Sorry for my poor English .

 

Vincent

  _____  

From: Denis, Rich [mailto:[email protected]] 
Sent: jeudi 22 janvier 2004 17:01
To: 'Vincent Daron'
Subject: RE: [Log4net-users] How to add an Appender to Log4net
programmatically at runtime ?

 

Try it without the MyAppender. i.e.  

 

 log4net.Config.BasicConfigurator.Configure()

 

Rich Denis
perotsystemsT

  _____  

From: Vincent Daron [mailto:[email protected]] 
Sent: Thursday, January 22, 2004 9:31 AM
To: [email protected]
Subject: [Log4net-users] How to add an Appender to Log4net programmatically
at runtime ?

 

Hi

 

By using log4net.Config.BasicConfigurator.Configure(MyAppender)

it run pretty fine, but I lost all the log4net configuration stored in the
config file.

 

Thanks for help

 

Vincent


------=_NextPart_000_002D_01C3E10E.9B4E2F50
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:st1=3D"urn:schemas-microsoft-com:office:smarttags" =
xmlns=3D"http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><o:SmartTagType
 namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags" =
name=3D"time"/>
<o:SmartTagType =
namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags"
 name=3D"date"/>
<o:SmartTagType =
namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags"
 name=3D"PersonName"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
	{font-family:"Trebuchet MS";
	panose-1:2 11 6 3 2 2 2 2 2 4;}
@font-face
	{font-family:"Franklin Gothic Medium";
	panose-1:2 11 6 3 2 1 2 2 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
h1
	{margin:0cm;
	margin-bottom:.0001pt;
	page-break-after:avoid;
	font-size:16.0pt;
	font-family:Arial;}
h2
	{margin-top:12.0pt;
	margin-right:0cm;
	margin-bottom:3.0pt;
	margin-left:0cm;
	page-break-after:avoid;
	font-size:14.0pt;
	font-family:"Times New Roman";
	font-style:italic;}
h3
	{margin-top:12.0pt;
	margin-right:0cm;
	margin-bottom:3.0pt;
	margin-left:0cm;
	page-break-after:avoid;
	font-size:13.0pt;
	font-family:Arial;}
h5
	{margin-top:12.0pt;
	margin-right:0cm;
	margin-bottom:3.0pt;
	margin-left:0cm;
	font-size:13.0pt;
	font-family:"Times New Roman";
	font-style:italic;}
p.MsoNormalIndent, li.MsoNormalIndent, div.MsoNormalIndent
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:36.0pt;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
p.MsoList, li.MsoList, div.MsoList
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:18.0pt;
	margin-bottom:.0001pt;
	text-indent:-18.0pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
p.MsoListBullet, li.MsoListBullet, div.MsoListBullet
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:18.0pt;
	margin-bottom:.0001pt;
	text-indent:-18.0pt;
	mso-list:l9 level1 lfo1;
	font-size:12.0pt;
	font-family:"Times New Roman";}
p.MsoListNumber, li.MsoListNumber, div.MsoListNumber
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:18.0pt;
	margin-bottom:.0001pt;
	text-indent:-18.0pt;
	mso-list:l8 level1 lfo2;
	font-size:12.0pt;
	font-family:"Times New Roman";}
p.MsoList2, li.MsoList2, div.MsoList2
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:36.0pt;
	margin-bottom:.0001pt;
	text-indent:-18.0pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
p.MsoList3, li.MsoList3, div.MsoList3
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:54.0pt;
	margin-bottom:.0001pt;
	text-indent:-18.0pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
p.MsoList4, li.MsoList4, div.MsoList4
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:72.0pt;
	margin-bottom:.0001pt;
	text-indent:-18.0pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
p.MsoList5, li.MsoList5, div.MsoList5
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:90.0pt;
	margin-bottom:.0001pt;
	text-indent:-18.0pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
p.MsoListBullet2, li.MsoListBullet2, div.MsoListBullet2
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:36.0pt;
	margin-bottom:.0001pt;
	text-indent:-18.0pt;
	mso-list:l7 level1 lfo3;
	font-size:12.0pt;
	font-family:"Times New Roman";}
p.MsoListBullet3, li.MsoListBullet3, div.MsoListBullet3
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:54.0pt;
	margin-bottom:.0001pt;
	text-indent:-18.0pt;
	mso-list:l6 level1 lfo4;
	font-size:12.0pt;
	font-family:"Times New Roman";}
p.MsoListBullet4, li.MsoListBullet4, div.MsoListBullet4
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:72.0pt;
	margin-bottom:.0001pt;
	text-indent:-18.0pt;
	mso-list:l5 level1 lfo5;
	font-size:12.0pt;
	font-family:"Times New Roman";}
p.MsoListBullet5, li.MsoListBullet5, div.MsoListBullet5
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:90.0pt;
	margin-bottom:.0001pt;
	text-indent:-18.0pt;
	mso-list:l4 level1 lfo6;
	font-size:12.0pt;
	font-family:"Times New Roman";}
p.MsoListNumber2, li.MsoListNumber2, div.MsoListNumber2
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:36.0pt;
	margin-bottom:.0001pt;
	text-indent:-18.0pt;
	mso-list:l3 level1 lfo7;
	font-size:12.0pt;
	font-family:"Times New Roman";}
p.MsoListNumber3, li.MsoListNumber3, div.MsoListNumber3
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:54.0pt;
	margin-bottom:.0001pt;
	text-indent:-18.0pt;
	mso-list:l2 level1 lfo8;
	font-size:12.0pt;
	font-family:"Times New Roman";}
p.MsoListNumber4, li.MsoListNumber4, div.MsoListNumber4
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:72.0pt;
	margin-bottom:.0001pt;
	text-indent:-18.0pt;
	mso-list:l1 level1 lfo9;
	font-size:12.0pt;
	font-family:"Times New Roman";}
p.MsoListNumber5, li.MsoListNumber5, div.MsoListNumber5
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:90.0pt;
	margin-bottom:.0001pt;
	text-indent:-18.0pt;
	mso-list:l0 level1 lfo10;
	font-size:12.0pt;
	font-family:"Times New Roman";}
p.MsoTitle, li.MsoTitle, div.MsoTitle
	{margin-top:12.0pt;
	margin-right:0cm;
	margin-bottom:3.0pt;
	margin-left:0cm;
	text-align:center;
	font-size:16.0pt;
	font-family:"Times New Roman";
	font-weight:bold;}
p.MsoBodyText, li.MsoBodyText, div.MsoBodyText
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:6.0pt;
	margin-left:0cm;
	font-size:12.0pt;
	font-family:"Times New Roman";}
p.MsoListContinue, li.MsoListContinue, div.MsoListContinue
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:6.0pt;
	margin-left:18.0pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
p.MsoListContinue2, li.MsoListContinue2, div.MsoListContinue2
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:6.0pt;
	margin-left:36.0pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
p.MsoListContinue3, li.MsoListContinue3, div.MsoListContinue3
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:6.0pt;
	margin-left:54.0pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
p.MsoListContinue4, li.MsoListContinue4, div.MsoListContinue4
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:6.0pt;
	margin-left:72.0pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
p.MsoListContinue5, li.MsoListContinue5, div.MsoListContinue5
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:6.0pt;
	margin-left:90.0pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
p.MsoMessageHeader, li.MsoMessageHeader, div.MsoMessageHeader
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:54.0pt;
	margin-bottom:.0001pt;
	text-indent:-54.0pt;
	background:#D9D9D9;
	font-size:12.0pt;
	font-family:"Times New Roman";}
p.MsoBodyText2, li.MsoBodyText2, div.MsoBodyText2
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:6.0pt;
	margin-left:0cm;
	line-height:200%;
	font-size:10.0pt;
	font-family:"Times New Roman";}
p.MsoBodyText3, li.MsoBodyText3, div.MsoBodyText3
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:6.0pt;
	margin-left:0cm;
	font-size:8.0pt;
	font-family:"Times New Roman";}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{color:purple;
	text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:8.0pt;
	font-family:Tahoma;}
p.titleheader, li.titleheader, div.titleheader
	{margin:0cm;
	margin-bottom:.0001pt;
	line-height:200%;
	font-size:12.0pt;
	font-family:"Trebuchet MS";}
p.sub-messageheader, li.sub-messageheader, div.sub-messageheader
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:54.0pt;
	margin-bottom:.0001pt;
	text-indent:-54.0pt;
	background:#D9D9D9;
	font-size:10.0pt;
	font-family:"Times New Roman";
	font-style:italic;}
p.sectionheader, li.sectionheader, div.sectionheader
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:54.0pt;
	margin-bottom:.0001pt;
	text-indent:-54.0pt;
	background:#D9D9D9;
	font-size:16.0pt;
	font-family:"Franklin Gothic Medium";}
p.titleheader0, li.titleheader0, div.titleheader0
	{margin:0cm;
	margin-bottom:.0001pt;
	line-height:200%;
	font-size:12.0pt;
	font-family:"Trebuchet MS";}
p.sub-messageheader0, li.sub-messageheader0, div.sub-messageheader0
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:54.0pt;
	margin-bottom:.0001pt;
	text-indent:-54.0pt;
	background:#D9D9D9;
	font-size:10.0pt;
	font-family:"Times New Roman";
	font-style:italic;}
p.sectionheader0, li.sectionheader0, div.sectionheader0
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:54.0pt;
	margin-bottom:.0001pt;
	text-indent:-54.0pt;
	background:#D9D9D9;
	font-size:16.0pt;
	font-family:"Franklin Gothic Medium";}
span.EmailStyle50
	{mso-style-type:personal;
	font-family:Arial;
	color:windowtext;}
span.EmailStyle51
	{mso-style-type:personal;
	font-family:Arial;
	color:navy;}
span.EmailStyle52
	{mso-style-type:personal;
	font-family:Arial;
	color:navy;}
span.EmailStyle53
	{mso-style-type:personal;
	font-family:Arial;
	color:navy;}
span.EmailStyle54
	{mso-style-type:personal-reply;
	font-family:Arial;
	color:navy;}
@page Section1
	{size:612.0pt 792.0pt;
	margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
	{page:Section1;}
 /* List Definitions */
 @list l0
	{mso-list-id:-132;
	mso-list-type:simple;
	mso-list-template-ids:632603720;}
@list l0:level1
	{mso-level-style-link:"List Number 5";
	mso-level-tab-stop:90.0pt;
	mso-level-number-position:left;
	margin-left:90.0pt;
	text-indent:-18.0pt;}
@list l1
	{mso-list-id:-131;
	mso-list-type:simple;
	mso-list-template-ids:-1297821960;}
@list l1:level1
	{mso-level-style-link:"List Number 4";
	mso-level-tab-stop:72.0pt;
	mso-level-number-position:left;
	margin-left:72.0pt;
	text-indent:-18.0pt;}
@list l2
	{mso-list-id:-130;
	mso-list-type:simple;
	mso-list-template-ids:93912562;}
@list l2:level1
	{mso-level-style-link:"List Number 3";
	mso-level-tab-stop:54.0pt;
	mso-level-number-position:left;
	margin-left:54.0pt;
	text-indent:-18.0pt;}
@list l3
	{mso-list-id:-129;
	mso-list-type:simple;
	mso-list-template-ids:1136925102;}
@list l3:level1
	{mso-level-style-link:"List Number 2";
	mso-level-tab-stop:36.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;}
@list l4
	{mso-list-id:-128;
	mso-list-type:simple;
	mso-list-template-ids:2039778894;}
@list l4:level1
	{mso-level-number-format:bullet;
	mso-level-style-link:"List Bullet 5";
	mso-level-text:\F0B7;
	mso-level-tab-stop:90.0pt;
	mso-level-number-position:left;
	margin-left:90.0pt;
	text-indent:-18.0pt;
	font-family:Symbol;}
@list l5
	{mso-list-id:-127;
	mso-list-type:simple;
	mso-list-template-ids:648035400;}
@list l5:level1
	{mso-level-number-format:bullet;
	mso-level-style-link:"List Bullet 4";
	mso-level-text:\F0B7;
	mso-level-tab-stop:72.0pt;
	mso-level-number-position:left;
	margin-left:72.0pt;
	text-indent:-18.0pt;
	font-family:Symbol;}
@list l6
	{mso-list-id:-126;
	mso-list-type:simple;
	mso-list-template-ids:-253723446;}
@list l6:level1
	{mso-level-number-format:bullet;
	mso-level-style-link:"List Bullet 3";
	mso-level-text:\F0B7;
	mso-level-tab-stop:54.0pt;
	mso-level-number-position:left;
	margin-left:54.0pt;
	text-indent:-18.0pt;
	font-family:Symbol;}
@list l7
	{mso-list-id:-125;
	mso-list-type:simple;
	mso-list-template-ids:-1716881046;}
@list l7:level1
	{mso-level-number-format:bullet;
	mso-level-style-link:"List Bullet 2";
	mso-level-text:\F0B7;
	mso-level-tab-stop:36.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	font-family:Symbol;}
@list l8
	{mso-list-id:-120;
	mso-list-type:simple;
	mso-list-template-ids:-1868502988;}
@list l8:level1
	{mso-level-style-link:"List Number";
	mso-level-tab-stop:18.0pt;
	mso-level-number-position:left;
	margin-left:18.0pt;
	text-indent:-18.0pt;}
@list l9
	{mso-list-id:-119;
	mso-list-type:simple;
	mso-list-template-ids:-122533968;}
@list l9:level1
	{mso-level-number-format:bullet;
	mso-level-style-link:"List Bullet";
	mso-level-text:\F0B7;
	mso-level-tab-stop:18.0pt;
	mso-level-number-position:left;
	margin-left:18.0pt;
	text-indent:-18.0pt;
	font-family:Symbol;}
ol
	{margin-bottom:0cm;}
ul
	{margin-bottom:0cm;}
-->
</style>

</head>

<body lang=3DEN-US link=3Dblue vlink=3Dpurple>

<div class=3DSection1>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>But when a new Logger is created, =
it receive
some appenders, I just like to be include in this list =
&#8230;.<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>I&#8217;ll look into the =
code&#8230;<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Thanks<o:p></o:p></span></font></p>

<div>

<div class=3DMsoNormal align=3Dcenter style=3D'text-align:center'><font =
size=3D3
face=3D"Times New Roman"><span style=3D'font-size:12.0pt'>

<hr size=3D2 width=3D"100%" align=3Dcenter tabindex=3D-1>

</span></font></div>

<p class=3DMsoNormal><b><font size=3D2 face=3DTahoma><span =
style=3D'font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font =
size=3D2
face=3DTahoma><span style=3D'font-size:10.0pt;font-family:Tahoma'> =
Denis, Rich
[mailto:[email protected]] <br>
<b><span style=3D'font-weight:bold'>Sent:</span></b> jeudi 22 janvier =
2004 17:34<br>
<b><span style=3D'font-weight:bold'>To:</span></b> 'Vincent Daron'<br>
<b><span style=3D'font-weight:bold'>Subject:</span></b> RE: =
[Log4net-users] How
to add an Appender to Log4net programmatically at runtime =
?</span></font><o:p></o:p></p>

</div>

<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>You make perfect sense.&nbsp;
Unfortunately I don&#8217;t think that you can do what you are trying to
do.&nbsp; You are only modifying the loggers that are known at the time =
you run
your code.&nbsp; The only way I could think that you would get it to =
work is to
somehow programmatically set the configuration file, but I am not sure =
how you
would do this.<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<div>

<p class=3DMsoNormal><font size=3D1 color=3Dnavy face=3D"Times New =
Roman"><span
style=3D'font-size:7.5pt;color:navy'>&nbsp;</span></font><font =
color=3Dnavy><span
style=3D'color:navy'> <o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dblack face=3DTahoma><span =
style=3D'font-size:
10.0pt;font-family:Tahoma;color:black'>Rich Denis</span></font><font =
size=3D1
color=3Dnavy face=3DTahoma><span =
style=3D'font-size:8.0pt;font-family:Tahoma;
color:navy'><br>
</span></font><b><font size=3D1 color=3Dred face=3DTahoma><span =
lang=3DEN-GB
style=3D'font-size:9.0pt;font-family:Tahoma;color:red;font-weight:bold'>p=
erot</span></font></b><b><font
size=3D1 color=3Dblack face=3DTahoma><span lang=3DEN-GB =
style=3D'font-size:9.0pt;
font-family:Tahoma;color:black;font-weight:bold'>systems</span></font></b=
><b><font
size=3D1 color=3Dblack face=3DTahoma><span =
style=3D'font-size:9.0pt;font-family:Tahoma;
color:black;font-weight:bold'>&#8482;</span></font></b><font =
color=3Dnavy><span
style=3D'color:navy'><o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D1 color=3Dblack face=3DArial><span =
style=3D'font-size:
7.5pt;font-family:Arial;color:black'>(972) 577-5869 =
Wk</span></font><font
color=3Dnavy><span style=3D'color:navy'><o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D3 color=3Dnavy face=3D"Times New =
Roman"><span
style=3D'font-size:12.0pt;color:navy'>&nbsp;</span></font><o:p></o:p></p>=


</div>

<div>

<div class=3DMsoNormal align=3Dcenter style=3D'text-align:center'><font =
size=3D3
face=3D"Times New Roman"><span style=3D'font-size:12.0pt'>

<hr size=3D2 width=3D"100%" align=3Dcenter tabindex=3D-1>

</span></font></div>

<p class=3DMsoNormal><b><font size=3D2 face=3DTahoma><span =
style=3D'font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font =
size=3D2
face=3DTahoma><span style=3D'font-size:10.0pt;font-family:Tahoma'> =
Vincent Daron
[mailto:[email protected]] <br>
<b><span style=3D'font-weight:bold'>Sent:</span></b> Thursday, <st1:date
Year=3D"2004" Day=3D"22" Month=3D"1" ls=3D"trans" w:st=3D"on">January =
22, 2004</st1:date>
<st1:time Minute=3D"23" Hour=3D"10" w:st=3D"on">10:23 AM</st1:time><br>
<b><span style=3D'font-weight:bold'>To:</span></b> <st1:PersonName =
w:st=3D"on">Denis,
 Rich</st1:PersonName><br>
<b><span style=3D'font-weight:bold'>Subject:</span></b> RE: =
[Log4net-users] How
to add an Appender to Log4net programmatically at runtime =
?</span></font><o:p></o:p></p>

</div>

<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<div>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Thanks, but it did&#8217;nt solve =
my
problem &#8230;<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>I&#8217;ll try to be =
clearer,<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>I&#8217;ve created an Appender, and =
I want
to &#8220;Attach&#8221; it on all the Loggers at runtime. I want to Add =
it to
the Appender specified in configuration file. I&#8217;ve found the =
following
code since my first post :<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
color=3Dblue
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier New";
color:blue'>foreach</span></font><font size=3D2 face=3D"Courier =
New"><span
style=3D'font-size:10.0pt;font-family:"Courier New"'>(ILoggerRepository =
tmp <font
color=3Dblue><span style=3D'color:blue'>in</span></font>
LoggerManager.GetAllRepositories())<o:p></o:p></span></font></p>

<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
face=3D"Courier New"><span
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>{<o:p></o:p></span></font></p>

<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
color=3Dblue
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier New";
color:blue'>&nbsp;&nbsp; foreach</span></font><font size=3D2 =
face=3D"Courier New"><span
style=3D'font-size:10.0pt;font-family:"Courier New"'>(Logger tmp2 <font
color=3Dblue><span style=3D'color:blue'>in</span></font> =
tmp.GetCurrentLoggers())<o:p></o:p></span></font></p>

<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
face=3D"Courier New"><span
style=3D'font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp; =
{<o:p></o:p></span></font></p>

<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
face=3D"Courier New"><span
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
tmp2.AddAppender(theAppender);<o:p></o:p></span></font></p>

<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
face=3D"Courier New"><span
style=3D'font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp; =
}<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D"Courier New"><span =
style=3D'font-size:10.0pt;
font-family:"Courier New"'>}<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D"Courier New"><span =
style=3D'font-size:10.0pt;
font-family:"Courier New"'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>The problem with this approach is =
that all
the assemblies loaded after this code do not log in My Appender (but =
they log
in the appenders specified in configuration). If I load these assemblies =
before
(by creating a dummy object for example), it run fine, and MyAppender =
receive
every LoggingEvent&#8230; I can&#8217;t do it for all the external =
assemblies
of course &#8230;.<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Thanks for =
answer<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Sorry for my poor English =
&#8230;<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Vincent<o:p></o:p></span></font></p>=


<div class=3DMsoNormal align=3Dcenter style=3D'text-align:center'><font =
size=3D3
face=3D"Times New Roman"><span style=3D'font-size:12.0pt'>

<hr size=3D2 width=3D"100%" align=3Dcenter tabindex=3D-1>

</span></font></div>

<p class=3DMsoNormal><b><font size=3D2 face=3DTahoma><span =
style=3D'font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font =
size=3D2
face=3DTahoma><span style=3D'font-size:10.0pt;font-family:Tahoma'> =
<st1:PersonName
w:st=3D"on">Denis, Rich</st1:PersonName> [mailto:[email protected]] <br>
<b><span style=3D'font-weight:bold'>Sent:</span></b> jeudi 22 janvier =
2004 17:01<br>
<b><span style=3D'font-weight:bold'>To:</span></b> 'Vincent Daron'<br>
<b><span style=3D'font-weight:bold'>Subject:</span></b> RE: =
[Log4net-users] How
to add an Appender to Log4net programmatically at runtime =
?</span></font><o:p></o:p></p>

</div>

<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Try it without the MyAppender. =
i.e.&nbsp; <o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<div>

<p class=3DMsoNormal><font size=3D1 color=3Dnavy face=3D"Times New =
Roman"><span
style=3D'font-size:7.5pt;color:navy'>&nbsp;</span></font><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>log4net.Config.BasicConfigurator.Configure()<o:p></o:p></span></fon=
t></p>

<p class=3DMsoNormal><font size=3D3 color=3Dnavy face=3D"Times New =
Roman"><span
style=3D'font-size:12.0pt;color:navy'><o:p>&nbsp;</o:p></span></font></p>=


<p class=3DMsoNormal><font size=3D2 color=3Dblack face=3DTahoma><span =
style=3D'font-size:
10.0pt;font-family:Tahoma;color:black'>Rich Denis</span></font><font =
size=3D1
color=3Dnavy face=3DTahoma><span =
style=3D'font-size:8.0pt;font-family:Tahoma;
color:navy'><br>
</span></font><b><font size=3D1 color=3Dred face=3DTahoma><span =
lang=3DEN-GB
style=3D'font-size:9.0pt;font-family:Tahoma;color:red;font-weight:bold'>p=
erot</span></font></b><b><font
size=3D1 color=3Dblack face=3DTahoma><span lang=3DEN-GB =
style=3D'font-size:9.0pt;
font-family:Tahoma;color:black;font-weight:bold'>systems</span></font></b=
><b><font
size=3D1 color=3Dblack face=3DTahoma><span =
style=3D'font-size:9.0pt;font-family:Tahoma;
color:black;font-weight:bold'>&#8482;</span></font></b><font =
color=3Dnavy><span
style=3D'color:navy'><o:p></o:p></span></font></p>

</div>

<div>

<div class=3DMsoNormal align=3Dcenter style=3D'text-align:center'><font =
size=3D3
face=3D"Times New Roman"><span style=3D'font-size:12.0pt'>

<hr size=3D2 width=3D"100%" align=3Dcenter tabindex=3D-1>

</span></font></div>

<p class=3DMsoNormal><b><font size=3D2 face=3DTahoma><span =
style=3D'font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font =
size=3D2
face=3DTahoma><span style=3D'font-size:10.0pt;font-family:Tahoma'> =
Vincent Daron
[mailto:[email protected]] <br>
<b><span style=3D'font-weight:bold'>Sent:</span></b> Thursday, <st1:date
Year=3D"2004" Day=3D"22" Month=3D"1" ls=3D"trans" w:st=3D"on">January =
22, 2004</st1:date>
<st1:time Minute=3D"31" Hour=3D"9" w:st=3D"on">9:31 AM</st1:time><br>
<b><span style=3D'font-weight:bold'>To:</span></b> <st1:PersonName =
w:st=3D"on">[email protected]</st1:PersonName><br>
<b><span style=3D'font-weight:bold'>Subject:</span></b> [Log4net-users] =
How to
add an Appender to Log4net programmatically at runtime =
?</span></font><o:p></o:p></p>

</div>

<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>Hi<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>By using </span></font><font size=3D2 face=3D"Courier =
New"><span
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>log4net.Config.BasicConfigurator.Configure(MyAppender)</span></font=
><font
size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'><o:p></o:p></span></font></p=
>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>it run pretty fine, but I lost all the log4net =
configuration
stored in the config file&#8230;<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>Thanks for help<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>Vincent<o:p></o:p></span></font></p>

</div>

</body>

</html>

------=_NextPart_000_002D_01C3E10E.9B4E2F50--




-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn