Hello Everyone,
I need to be able to configure log4net without the XmlConfigurator, that is
directly from my code.
I am aware of the BasicConfigurator but one appender is not enough for me.
I would like to be able to create some new appenders, remove (or disable)
them and change their
log threshold at runtime. I am working under Compact Framework 2.0.
I already took a look at this (
http://www.mail-archive.com/[email protected]/msg02895.html )
mail that gave me many informations,
but did not yet found how to create an appender and register it not for one
logger but for all (and all the ones that will be created after I registered my
appender).
In fact how can I achieve a configuration like the following file but
programmatically:
<configuration>
<log4net>
<appender name="TextLogFileAppender" type="log4net.Appender.FileAppender" >
<file value="log.xml" />
<appendToFile value="true" />
<layout type="log4net.Layout.XmlLayoutSchemaLog4j" />
<param name="Threshold" value="ERROR" />
</appender>
<appender name="ConsoleErrorAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%ndc]
<%property{auth}> - %message%newline" />
</layout>
<param name="Threshold" value="FATAL" />
</appender>
<appender name="UdpAppender" type="log4net.Appender.UdpAppender">
<localPort value="8080" />
<remoteAddress value="192.168.1.1" />
<remotePort value="8080" />
<layout type="log4net.Layout.XmlLayoutSchemaLog4j">
<locationInfo value="true" />
</layout>
<param name="Threshold" value="DEBUG" />
</appender>
<!-- Setup the root category, add the appenders and set the default level -->
<root>
<appender-ref ref="TextLogFileAppender" />
<appender-ref ref="ConsoleErrorAppender" />
<appender-ref ref="UdpAppender" />
</root>
</log4net>
</configuration>
Best regards and many thanks in advance for any help,
Bruno
Bruker BioSpin GmbH
_____
Bruno Knittel
Automation Development
Bruker BioSpin GmbH
Silberstreifen
76287 Rheinstetten
Germany Phone: +49 721 5161-90064
Fax: +49 721 5161-494
[EMAIL PROTECTED]
www.bruker-biospin.com <http://www.bruker-biospin.com/>
_____
Bruker BioSpin GmbH: Sitz der Gesellschaft/Registered Office: Rheinstetten, HRB
102368 Amtsgericht Mannheim
Geschäftsführer/Managing Directors: Dr. Bernd Gewiese, Dr. Dieter Schmalbein,
Dr. Gerhard Roth
Diese E-Mail und alle Anlagen können Betriebs- oder Geschäftsgeheimnisse, oder
sonstige vertrauliche Informationen enthalten. Sollten Sie diese E-Mail
irrtümlich erhalten haben, ist Ihnen eine Kenntnisnahme des Inhalts, eine
Vervielfältigung oder Weitergabe der E-Mail und aller Anlagen ausdrücklich
untersagt. Bitte benachrichtigen Sie den Absender und löschen/vernichten Sie
die empfangene E-Mail und alle Anlagen.
Vielen Dank.
This message and any attachments may contain trade secrets or privileged,
undisclosed or otherwise confidential information. If you have received this
e-mail in error, you are hereby notified that any review, copying or
distribution of it and its attachments is strictly prohibited. Please inform
the sender immediately and delete/destroy the original message and any copies.
Thank you.