logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joseph_g...@bankone.com
Subject issue with AdoNetAdapter
Date Tue, 14 Jun 2005 17:50:59 GMT
First let me give some background info, then I will describe my issue...
1. VS.NET 2003
2. .NET runtime 1.1
3. Log4Net version 1.2.9
4. Windows Form application. uses log4net.dll debug version.
5. Connecting to Oracle 9i database

I am trying to set up log4net to log to an AdoNetAppender for Oracle 9i. 
When I went to test, I could
not get any log messages to write to the database. I verified that the 
output from the logger 
initialization was not throwing any log4net errors. So to ensure that I 
was connecting ok to the database, 
I put in a simple call to the same database I am trying to log messages to 

(i.e. con.Open(), cmd.Execute, con.Close()). To my surprise, once I added 
this call, 
the logging worked, even if I close the connection before logging a 
message. But when I comment out 
again, the logging stopped working again. So it almost looks to me like it 
needs me to open a 
connection to the database before I ever start logging to it, even though 
the connection string 
for the log4net configuration is different than the one used for the 
simple sql test. Shouldn't 
the AdoNetAppender open the connection using it's settings up front...or 
am I missing something 
in the documentation? I included my App.config log4net configuration 
section below...

  <section name="log4net" 
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
  <appender name="OracleAppender" type="log4net.Appender.AdoNetAppender">
    <connectionType value="System.Data.OracleClient.OracleConnection, 
System.Data.OracleClient, Version=1.0.5000.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089" />
    <connectionString value="left out, but a valid connection string being 
used elsewhere" />
    <commandText value="insert into SOME_LOG 
(:log_date,:log_level,:message,:exception)" />
    <bufferSize value="128" />
      <parameterName value=":log_date" />
      <dbType value="DateTime" />
      <layout type="log4net.Layout.RawTimeStampLayout" />
      <parameterName value=":log_level" />
      <dbType value="String" />
      <size value="25" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%level" />
      <parameterName value=":message" />
      <dbType value="String" />
      <size value="4000" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%message" />
      <parameterName value=":exception" />
      <dbType value="String" />
      <size value="4000" />
      <layout type="log4net.Layout.ExceptionLayout" />
    <level value="INFO" />
    <appender-ref ref="OracleAppender" />

This transmission may contain information that is privileged, confidential and/or exempt from
disclosure under applicable law. If you are not the intended recipient, you are hereby notified
that any disclosure, copying, distribution, or use of the information contained herein (including
any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error,
please immediately contact the sender and destroy the material in its entirety, whether in
electronic or hard copy format. Thank you.

View raw message