[Pljava-dev] Re: Log4j

From: thhal at mailblocks(dot)com (Thomas Hallgren)
To:
Subject: [Pljava-dev] Re: Log4j
Date: 2005-01-06 11:10:12
Message-ID: thhal-0FrW4Am3rcS4LU1lRX2I78N0+NNi8cN@mailblocks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

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

Browse pljava-dev by date

  From Date Subject
Next Message Nageshwar Rao 2005-01-10 14:38:09 [Pljava-dev] Trigger
Previous Message Thomas Hallgren 2004-12-30 09:49:21 [Pljava-dev] support for 8.0.0rc2?