The current implementation doesn't allow a sub-class to easily provide its own 
IDbConnection. You'll have to copy and paste the contents of AdoNetAppender and 
modify the code to fit your needs.

AdoNetAppender needs a little refactoring so things like this are possible.

----- Original Message ----
From: Szymon Rozga <[EMAIL PROTECTED]>
To: Log4NET User <[email protected]>
Sent: Tuesday, January 29, 2008 9:39:17 PM
Subject: ADO.Net Appender connection troubles


I 
am 
trying 
to 
use 
the 
AdoNetAppender, 
but 
I 
am 
in 
an 
environment 
in
which 
the 
connection 
string 
is 
dynamic, 
depending 
on 
which 
of 
a 
series
of 
servers 
the 
app 
connects 
to. 
My 
idea 
is 
to 
get 
a 
reference 
to 
the
appender 
and 
reset 
the 
ConnectionString 
when 
my 
app 
knows 
which 
server
I 
am 
connecting 
to.

This 
sounds 
fine, 
but 
I 
only 
have 
access 
to 
an 
instance 
of 
an
IDbConnection. 
The 
ConnectionString 
property 
on 
that 
class 
returns 
the
connection 
string 
without 
the 
password, 
not 
surprisingly. 
This 
means
that 
when 
I 
set 
the 
ConnectionString 
property 
on 
the 
Appender 
and 
it
attempts 
to 
reconnect 
on 
error, 
it 
complains 
that 
I 
did 
not 
provide 
a
password.

Is 
it 
possible 
to 
set 
up 
the 
appender 
to 
somehow 
use 
a 
IDbConnection
instance 
instead 
of 
specifying 
the 
connection 
type 
and 
a 
connection
string 
and 
having 
log4net 
open 
another 
connection?

I 
have 
tried 
creating 
a 
subclass 
of 
AdoNetAppender 
exposing 
the
Connection 
property 
(so 
I 
am 
able 
to 
set 
the 
connection 
itself), 
but
that 
doesn't 
really 
fix 
it 
since 
it 
seems 
some 
internal 
state 
is 
being
held 
by 
AdoNetAppender. 
Allowing 
the 
class 
to 
reconnect 
on 
failure
tries 
to 
use 
the 
connection 
string, 
which 
doesn't 
really 
help.

Any 
ideas?

-Szymon



Reply via email to