logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Grabowski <rongrabow...@yahoo.com>
Subject Re: Extending Log4Net
Date Sat, 17 Jun 2006 18:45:58 GMT
The SmtpAppender has parameters named "to" and "from":

 <to value="to@domain.com" />
 <from value="from@domain.com" />

This is what those parameters look like in code on the SmtpAppender
class:

 public string To 
 {
  get { return m_to; }
  set { m_to = value; }
 }
 
 public string From 
 {
  get { return m_from; }
  set { m_from = value; }
 }

Your SMSAppender should have a public property named
SMS_Alert_MobileNumbers:

 public string SMS_Alert_MobileNumbers
 {
  get { return smsAlertMobileNumbers; }
  set { smsAlertMobileNumbers = value; }
 } 

Here's what your config file will look like:

 <?xml version="1.0" encoding="utf-8" ?>
 <log4net>
  <appender name="SMSAppender" 
   type="CustomLog4NetAppenders.SMSAppender, CustomLog4NetAppenders">
   <SMS_Alert_MobileNumbers value="5628241460" />
  </appender>
  <root>
   <appender-ref ref="SMSAppender" />
  </root>
 </log4net>

The error message you're seeing is log4net telling you its unable to
find a property named "SMS_Alert_MobileNumbers" on one of log4net's
internal objects.

--- TJO <tim@theodells.org> wrote:

> 
> 
> I have reviewed the sample code and am still not understanding how
> param's are
> entered.  My logger requires a custom parameter as shown below:
> 
> <appender name='SMSAppender' threshold='ERROR'
> type='CustomLog4NetAppenders.SMSAppender, CustomLog4NetAppenders'>
>   <param name='SMS_Alert_MobileNumbers' value='5628241460'></param>
> </appender>
> 
> In my Custom Appender class that extends AppenderSkeleton I am lost
> on how to
> setup and map the param value to my class's properties.  When I
> executed my code
> I see the following error:
> 
> log4net:ERROR XmlHierarchyConfigurator: Cannot find Property
> [SMS_Alert_MobileNumbers] to set object on
> [log4net.Repository.Hierarchy.DefaultLoggerFactory+LoggerImpl]
> 
> Can someone show me or direct me to somewhere where I can see this
> implemented?
> 
> 
> 
> 
> 


Mime
View raw message