Return-Path: Delivered-To: apmail-logging-log4j-user-archive@www.apache.org Received: (qmail 90607 invoked from network); 2 Apr 2008 16:13:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Apr 2008 16:13:48 -0000 Received: (qmail 26270 invoked by uid 500); 2 Apr 2008 16:13:47 -0000 Delivered-To: apmail-logging-log4j-user-archive@logging.apache.org Received: (qmail 26247 invoked by uid 500); 2 Apr 2008 16:13:47 -0000 Mailing-List: contact log4j-user-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Log4J Users List" Reply-To: "Log4J Users List" Delivered-To: mailing list log4j-user@logging.apache.org Received: (qmail 26210 invoked by uid 99); 2 Apr 2008 16:13:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Apr 2008 09:13:47 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of hoju@visi.com designates 208.42.176.221 as permitted sender) Received: from [208.42.176.221] (HELO g2host.com) (208.42.176.221) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Apr 2008 16:13:04 +0000 Received: from [162.136.192.1] (account hoju@visi.com) by mailback2.g2host.com (CommuniGate Pro WEBUSER 5.1.14) with HTTP id 8896643 for log4j-user@logging.apache.org; Wed, 02 Apr 2008 11:13:11 -0500 From: "Jacob Kjome" Subject: Re: JDBCAppender and DB passwords To: "Log4J Users List" X-Mailer: CommuniGate Pro WebUser v5.1.14 Date: Wed, 02 Apr 2008 11:13:11 -0500 Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1;format="flowed" Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org There's a couple ways. Both involve referencing variables set externally. For instance... ${db.username} ${db.password) You can make these variables available in one of two ways (only the first way below if you are using XML config).... 1. Set it as a system property. e.g... java -Ddb.username=[username] -Ddb.password=[password] 2. You can manually configure using the PropertyConfigurator and pass in variables prior to calling configure() (can't recall the exact API to do this at the moment, but you can look it up). I have't worked with the JDBCAppender much. I wonder if you couldn't just give it a JNDI name of the DataSource it is supposed to use? In that case, the above would be unnecessary. Jake On Wed, 2 Apr 2008 23:37:27 +1100 "Annie Lane" wrote: > Hi list, > > I'm using log4j-1.2.14 and want to play with JDBCAppender. My main concern > is the fact that in my log4j.properties file I need to provide the username > and password details for the database connection. > > How can I use JDBCAppender without having to put this information in my > .properties file? > > Additionally, how might I inject a database connection from within my > application? Say I'm developing a JEE app which contains its own connection > pooling mechanisms etc. > > Any help/advice would be very much appreciated. > > Annie --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org For additional commands, e-mail: log4j-user-help@logging.apache.org