From: thhal at mailblocks.com (Thomas Hallgren) Date: Thu, 06 Jan 2005 12:10:12 +0100 Subject: [Pljava-dev] Re: Log4j In-Reply-To: <5F4ED4205E00D6119BFE009027DE39090793EFEF@MLSW00103> References: <5F4ED4205E00D6119BFE009027DE39090793EFEF@MLSW00103> <41DD1C94.7060506@mailblocks.com> Message-ID: Nageshwar, >Hi, > >I am trying use log4j logging as part of my code, >I install log4j jar, >while executing following error message is displayed > >"log4j:WARN No appenders could be found for logger >(com.ge.gis.pgtrigger.EventTrigger). >log4j:WARN Please initialize the log4j system properly." > >Basically it is not able to find log4j.properties file. > > log4j needs a properties file that it can find in the classpath. You'll need to include such a file in a jar that you load using sqlj.install_jar. Personally, I'd refrain from using log4j since the JRE is bundled with a good logging package. Adding yet another (fairly extensive) logging package will waste resources. >We tried using Logger.getAnonymousLogger() also, but couldn't locate the >package for this. > > The Logger is in java.util.logging. It's bundled with the java runtime. The PLJava router for this can be found in org.postgresql.pljava.internal. It's setup automatically by the PLJava runtime. PLJava will route logs printed using the java.util.logging.Logger to the PostgreSQL elog mechanism. That in turn, will produce a logfile somewhere (depends on your PostgreSQL configuration). The mapping of log levels between Java and the PostgreSQL elog handler is as follows (exerpt from org.postgresql.pljava.internal.ELogHandler): if(level == null) pgLevel = LOG_LOG; else if(level.equals(Level.SEVERE)) pgLevel = LOG_ERROR; else if(level.equals(Level.WARNING)) pgLevel = LOG_WARNING; else if(level.equals(Level.INFO)) pgLevel = LOG_INFO; else if(level.equals(Level.FINE)) pgLevel = LOG_DEBUG1; else if(level.equals(Level.FINER)) pgLevel = LOG_DEBUG2; else if(level.equals(Level.FINEST)) pgLevel = LOG_DEBUG3; else pgLevel = LOG_LOG; I'd appreciate if you could send future questions to the pljava-dev at gborg.postgresql.org instead of to me personally. The idea of open source is better honored that way. Everyone can see all questions and benefit from all replies. Another important aspect of this is that all invovled have a chance to reply and convey their experiences. Kind regards, Thomas Hallgren