I also created an ADONetReturnValueAppenderParameter at the bottom of
the ADONetReturnValueAppender.cs. You may have to override some privates
in the ADONetAppenderParameter class to accommodate this also. 

And to get a jump on your next potential question, instead of using the
regular ILog, I created a custom log implementation, according to
suggestions on this list, called IParameterLog which allows you to pass
a data parameter collection into each log call and those parameters will
be used when writing/reading to the database. To get immediate return
values, however, you have to have your BufferSize set to 1 in the
configuration of your ADONetReturnValueAppender.

Aaron

-----Original Message-----
From: Diego Barros [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 08, 2005 11:08 PM
To: Log4NET User
Subject: RE: ADONETAppender and stored procedures

Hi Aaron,

I tried your ADONetReturnValueAppender but am getting the error below.
Now,
I changed all the private intsnaces in ADONetAppender to protected, as
per
your comment in the follow-up email.

Tracing through the source I think the ambigiouity is due to the
different
signatured of the AddParameter method in ADONetReturnValueAppender and
ADONetValueAppender.
Well, that's my guess anyway. 

public virtual void AddParameter(ADONetReturnValueAppenderParameter
parameter);

Is there something else you have changed in ADONetAppender.cs which I
may
also need to do?

Thanks.

Cheers,
Diego


----------------

log4net: DOMConfigurator: Configuration update mode [Merge].
log4net: DOMConfigurator: Rendering class
[Log4NETTest.AuditEventIDRenderer,
Log
4NETTest], Rendered class [Log4NETTest.AuditEvent, Log4NETTest].
log4net: DOMConfigurator: Rendering class
[Log4NETTest.AuditEventAdditionalDetai
lsRenderer, Log4NETTest], Rendered class [Log4NETTest.AuditEvent,
Log4NETTest].
log4net: DOMConfigurator: Logger [root] Level string is [DEBUG].
log4net: DOMConfigurator: Logger [root] level set to
[name="DEBUG",value=30000].

log4net: DOMConfigurator: Loading Appender [AuditEventAppender] type:
[log4net.A
ppender.ADONetReturnValueAppender]
log4net: DOMConfigurator: Setting Property [BufferSize] to Int32 value
[1]
log4net: DOMConfigurator: Setting Property [ConnectionType] to String
value
[Sys
tem.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0,
Culture=neutr
al, PublicKeyToken=b77a5c561934e089]
log4net: DOMConfigurator: Setting Property [ConnectionString] to String
value [d
ata source=localhost;initial catalog=TestDB;integrated
security=false;persist
se
curity info=True;User ID=sa;Password=]
log4net: DOMConfigurator: Setting Property [CommandText] to String value
[usp_Lo
gAuditEvent]
log4net: DOMConfigurator: Setting Property [CommandType] to CommandType
value [S
toredProcedure]
log4net:ERROR DOMConfigurator: Could not create Appender
[AuditEventAppender]
of
 type [log4net.Appender.ADONetReturnValueAppender]. Reported error
follows.
System.Reflection.AmbiguousMatchException: Ambiguous match found.
   at System.RuntimeType.GetMethodImplInternal(String name, BindingFlags
binding
Attr, Binder binder, CallingConventions callConvention, Type[] types,
ParameterM
odifier[] modifiers, Boolean verifyAccess)
   at System.RuntimeType.GetMethodImpl(String name, BindingFlags
bindingAttr,
Bi
nder binder, CallingConventions callConvention, Type[] types,
ParameterModifier[
] modifiers)
   at System.Type.GetMethod(String name, BindingFlags bindingAttr)
   at
log4net.Repository.Hierarchy.DOMHierarchyConfigurator.SetParameter(XmlEl
em
ent element, Object target) in
c:\development\log4net-1.2.0-beta8\src\repository
\hierarchy\domhierarchyconfigurator.cs:line 508
   at
log4net.Repository.Hierarchy.DOMHierarchyConfigurator.ParseAppender(XmlE
le
ment appenderElement) in
c:\development\log4net-1.2.0-beta8\src\repository\hiera
rchy\domhierarchyconfigurator.cs:line 286
log4net:ERROR DOMConfigurator: Appender named [AuditEventAppender] not
found.
log4net: DOMConfigurator: Hierarchy Threshold []
log4net: Logger: No appenders could be found for logger [myLogger]
repository
[l
og4net-default-domain]
log4net: Logger: Please initialize the log4net system properly.
log4net: Logger:    Current AppDomain context information:
log4net: Logger:       BaseDirectory   :
D:\Code\C#\Log4NETTest\Log4NETTest\bin\
Debug\
log4net: Logger:       FriendlyName    : Log4NETTest.exe
log4net: Logger:       DynamicDirectory:
Done.

---------------

>-- Original Message --
>Reply-To: "Log4NET User" <[email protected]>
>Subject: RE: ADONETAppender and stored procedures
>Date: Tue, 8 Feb 2005 08:50:16 -0700
>From: "Hart, Aaron" <[EMAIL PROTECTED]>
>To: "Log4NET User" <[email protected]>
>
>
>I should also note that I had to change the ADONETAppender class to use
>protected variables and functions instead of private in order to
inherit
>from it.
>
>Aaron Hart
>
>-----Original Message-----
>From: Hart, Aaron 
>Sent: Tuesday, February 08, 2005 7:25 AM
>To: 'Log4NET User'
>Subject: RE: ADONETAppender and stored procedures
>
>Diego,
>  I have done this exact thing, although my intentions were different.
I
>wanted to create a logging table that has an auto-increment field and
be
>able to return the value for that field. Since each logging call could
>go be written to multiple ADONETAppenders and therefore have several
>sets of result data, the return values are put into an array as
>suggested by Nicko. I have been waiting to post my new class on this
>list because it has only been minimally tested, but if there is already
>need for it, here it is.
>  I hope I can attach files to this email. If they get filtered off
this
>message, I can send them directly to you. Just add these files into the
>existing project according to their namespaces. Of course, feel free to
>change them as needed.
>
>Aaron Hart
>
>-----Original Message-----
>From: Diego Barros [mailto:[EMAIL PROTECTED] 
>Sent: Monday, February 07, 2005 10:32 PM
>To: [email protected]
>Subject: ADONETAppender and stored procedures
>
>Hi all,
>
>I was wondering if the ADONETAppender could make use of output stored
>procedure
>parameters? I wish the logging to call a stored procedure and then have
>it return some values (via output parameters), then use the returned
>values
>elsewhere. For example, I wish to log to the event log the returned
>values
>from the stored procedure.
>
>Would I be better off implementing my own appender (by taking the
>ADONetAppender)
>and making it do what I want, like get the returned values from the
>stored
>procedure?
>
>Any help or pointers as to how I can implement this would be greatly
>appreciated.
>
>Cheers,
>Diego
>


Reply via email to