From: Guy Rouillier <guyr-ml1@burntmail.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: Log4j Appender
Date: Fri, 20 Mar 2009 23:37:26 -0400
Message-ID: <49C460F6.6070603@burntmail.com> (raw)
In-Reply-To: <20090320110636.322130@gmx.net>
References: <20090320110636.322130@gmx.net>
nenad.jaksic@imail.de wrote:
> Hello,
>
> I'd like to use DBAppender or JDBCAppender to log to Postgres
> DB, I am not sure if any can send me some peace of code or clue or link
> how to do it. I also use Hibernete so I know
> there is also way to connect it to Hibernate to but preference
> is to make it with Log4j anyhow.
> Does somebody knows the correct way?
This works for me:
table:
----------------
create table log4j_messages
(
message varchar(2000),
class varchar(255),
priority varchar(64),
log_date timestamp
);
log4j.properties:
-----------------
### JDBC appender
# timestamp comes out like this: 2009-03-20 22:16:45,614
log4j.appender.jdbc=org.apache.log4j.jdbc.JDBCAppender
log4j.appender.jdbc.driver=org.postgresql.Driver
log4j.appender.jdbc.URL=jdbc:postgresql://localhost:5432/postgres
log4j.appender.jdbc.user=xxxxx
log4j.appender.jdbc.password=yyyyy
log4j.appender.jdbc.sql=INSERT INTO log4j_messages (message, class,
priority, log_date) values ('%m', '%c', '%p', to_timestamp('%d',
'YYYY-MM-DD HH24:MI:SS,MS'))
--
Guy Rouillier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: guyr-ml1@burntmail.com
Subject: Re: Log4j Appender
In-Reply-To: <49C460F6.6070603@burntmail.com>
References: <20090320110636.322130@gmx.net> <49C460F6.6070603@burntmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox