Discussion:
AdoNetAppender and PostgreSQL
Nuno Rocha
2007-09-18 17:03:17 UTC
Permalink
Hi,

I'm trying to use log4net to log events into a database in PostgreSQL.
There is no indication in the website if this is supported or example
configurations.

Is it possible for anyone to tell me if this is possible and, if yes, how?

Regards,
Nuno
Ron Grabowski
2007-09-18 21:14:29 UTC
Permalink
If there is an ADO.Net driver for PostgrSQL that implement IDbConnection, IDbCommand, etc. then its supported.

----- Original Message ----
From: Nuno Rocha <***@gmail.com>
To: log4net-***@logging.apache.org
Sent: Tuesday, September 18, 2007 1:03:17 PM
Subject: AdoNetAppender and PostgreSQL

Hi,

I'm trying to use log4net to log events into a database in PostgreSQL.
There is no indication in the website if this is supported or example configurations.

Is it possible for anyone to tell me if this is possible and, if yes, how?


Regards,
Nuno
Nuno Rocha
2007-09-19 08:25:59 UTC
Permalink
Hmm, I'm using Npgsql as provider for data access.
NpgsqlConnection inherits DbConnection and so forth.

I've tried to put this working with the following configuration:

<appender name="AdoNetAppender_PGSQL" type="log4net.Appender.AdoNetAppender
">
<connectionType value="Npgsql.NpgsqlConnection, Npgsql"/>
<connectionString value="Server=localhost;Database=db;User
id=user;Password=pass;" />
<commandText value="INSERT INTO errors
(date,thread,level,logger,message) VALUES (:log_date, :thread, :log_level,
:logger, :message)" />
<parameter>
<parameterName value="log_date" />
<dbType value="DateTime" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{yyyy'/'MM'/'dd
HH':'mm':'ss'.'fff}" />
</layout>
</parameter>
<parameter>
<parameterName value="thread" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%thread" />
</layout>
</parameter>
<parameter>
<parameterName value="log_level" />
<dbType value="String" />
<size value="50" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%level" />
</layout>
</parameter>
<parameter>
<parameterName value="logger" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%logger" />
</layout>
</parameter>
<parameter>
<parameterName value="message" />
<dbType value="String" />
<size value="4000" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%message" />
</layout>
</parameter>
</appender>

There are no errors in the configuration process and no exception is thrown
when logging, but no data appear in the database....

Any help??
Post by Ron Grabowski
If there is an ADO.Net driver for PostgrSQL that implement IDbConnection,
IDbCommand, etc. then its supported.
----- Original Message ----
Sent: Tuesday, September 18, 2007 1:03:17 PM
Subject: AdoNetAppender and PostgreSQL
Hi,
I'm trying to use log4net to log events into a database in PostgreSQL.
There is no indication in the website if this is supported or example configurations.
Is it possible for anyone to tell me if this is possible and, if yes, how?
Regards,
Nuno
Nuno Rocha
2007-09-19 09:49:51 UTC
Permalink
Ok, got it working.

More exactly, it was already working...but it wouldn't show anything in the
database because the bufferSize attribute was the default one...so it would
only log after 512 log entries...
I added <bufferSize value="1" /> to the configuration and it showed
immediately.

I hope this helps someone that is as distracted as me...
Post by Nuno Rocha
Hmm, I'm using Npgsql as provider for data access.
NpgsqlConnection inherits DbConnection and so forth.
<appender name="AdoNetAppender_PGSQL" type="
log4net.Appender.AdoNetAppender">
<connectionType value="Npgsql.NpgsqlConnection, Npgsql"/>
<connectionString value="Server=localhost;Database=db;User
id=user;Password=pass;" />
<commandText value="INSERT INTO errors
(date,thread,level,logger,message) VALUES (:log_date, :thread, :log_level,
:logger, :message)" />
<parameter>
<parameterName value="log_date" />
<dbType value="DateTime" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{yyyy'/'MM'/'dd
HH':'mm':'ss'.'fff}" />
</layout>
</parameter>
<parameter>
<parameterName value="thread" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%thread" />
</layout>
</parameter>
<parameter>
<parameterName value="log_level" />
<dbType value="String" />
<size value="50" />
<layout type="log4net.Layout.PatternLayout ">
<conversionPattern value="%level" />
</layout>
</parameter>
<parameter>
<parameterName value="logger" />
<dbType value="String" />
<size value="255" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%logger" />
</layout>
</parameter>
<parameter>
<parameterName value="message" />
<dbType value="String" />
<size value="4000" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%message" />
</layout>
</parameter>
</appender>
There are no errors in the configuration process and no exception is
thrown when logging, but no data appear in the database....
Any help??
Post by Ron Grabowski
If there is an ADO.Net driver for PostgrSQL that implement
IDbConnection, IDbCommand, etc. then its supported.
----- Original Message ----
Sent: Tuesday, September 18, 2007 1:03:17 PM
Subject: AdoNetAppender and PostgreSQL
Hi,
I'm trying to use log4net to log events into a database in PostgreSQL.
There is no indication in the website if this is supported or example configurations.
Is it possible for anyone to tell me if this is possible and, if yes, how?
Regards,
Nuno
Loading...