logging-log4net-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ron Grabowski (JIRA)" <j...@apache.org>
Subject [jira] Commented: (LOG4NET-20) [PATCH] Adds "extends" attribute to appenders
Date Wed, 09 Nov 2005 23:05:03 GMT
    [ http://issues.apache.org/jira/browse/LOG4NET-20?page=comments#action_12357162 ] 

Ron Grabowski commented on LOG4NET-20:

Time to change my mind again :-) I doubt we can use this syntax:

 <appender name="SpecializedFileAppender" type="log4net.Appender.ExtendAppender">
  <extends value="BaseFileAppender" />
  <file value="special.txt" />

becuase ActivateOptions tries to set properties on the class in which its called. In the above
example, it would be trying to set the File property of the ExtendAppender class. Things would
still be complicated even if ActivateOptions accepted an IDictionary. For simple cases like
this it may be ok:

 public override void ActivateOptions(IDictionary options)
  string file = options["file"]; // special.txt

How would one access these values?

   <parameterName value="@log_date" />
  <dbType value="DateTime" />
  <layout type="log4net.Layout.RawTimeStampLayout" />
   <parameterName value="@log_date" />
  <dbType value="DateTime" />
  <layout type="log4net.Layout.RawTimeStampLayout" />

 // UGLY!
 object dbType =  options["parameter"][0]["dbType""];

We can't return an XmlNode of the sub-item because there's no guarantee that that user is
using the XmlConfigurator.

Something like this may work:

<appender name="SpecializedFileAppender" type="log4net.Appender.ExtendAppender">
  <extends value="TempAppender" />
   <parameterName value="@log_date" />
  <dbType value="DateTime" />
  <layout type="log4net.Layout.RawTimeStampLayout" />

but it can get ugly very fast. Plus that's a lot of text to type just to override one property...

> [PATCH] Adds "extends" attribute to appenders
> ---------------------------------------------
>          Key: LOG4NET-20
>          URL: http://issues.apache.org/jira/browse/LOG4NET-20
>      Project: Log4net
>         Type: Improvement
>   Components: Appenders
>     Versions: 1.2.9
>  Environment: WinXP, .NET Framework 1.1
>     Reporter: Dag Christensen
>     Priority: Trivial
>  Attachments: DOMHierarchyConfigurator.patch
> Adds "extends" attribute to appenders. Improvement suggested by Ron Grabowski on log4net-user.
> Sample usage:
> <appender name="LogFileAppenderBase" type="log4net.Appender.RollingFileAppender">
> 	<param name="CountDirection" value="1"/>
> 	<param name="AppendToFile" value="true"/>
> 	<param name="MaxSizeRollBackups" value="10"/>
> 	<param name="MaximumFileSize" value="5MB"/>
> 	<param name="RollingStyle" value="Size"/>
> 	<param name="StaticLogFileName" value="true"/>
> </appender>
> <appender name="LogFileAppenderDefaultLayout" extends="LogFileAppenderBase">
> 	<layout type="log4net.Layout.PatternLayout">
> 		<param name="ConversionPattern" value="%d{dd.MM.yy HH:mm:ss} [%t] %-5p %c{1} %m
> 	</layout>
> </appender>
> <appender name="LogFileAppender" extends="LogFileAppenderDefaultLayout">
> 	<param name="File" value="log.txt"/>
> </appender>

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

View raw message