Hi Anjana,
I'm not an expert on using log4j but it seems to be loaded with
features. I'm confident that you can find a way to force the default
Logger to write to a PrintStream which you have created. For instance, I
believe that the default logger is an
org.apache.logging.log4j.simple.SimpleLogger, and that class has a
setStream() method. What you need to do is create a static public method
which returns a PrintStream which writes to the file of your choice.
Poke that PrintStream into the log4j machinery. You can poke that
PrintStream into Derby by pointing derby.stream.error.field at the
static public method which you created.
More inline...
On 12/22/15 9:26 AM, Anjana Prakash wrote:
Hi Rick,
Thanks for follow-up. I looked into the option of
derby.stream.error.file. However there is issue accessing this value
of this in system procedure.
My requirement is in system procedure I have implemented log4j. We
want all the logging from procedure and log level should be using
derby.log.
Question is
1.Is there any logger API existing in derby that can be used in system
procedure
2.Is there is way to log to derby.log using log4j from our system
procedure
What you want to do is force Derby to use the PrintStream being used by
log4j.
3.We have not set derby.stream.error.file i.e. want the default
derby.log Then why is accessing value of derby.stream.error.file
using system property return null.
I'm afraid I don't understand the question.
4.Also system procedure that refers log4j fail with classnotfound
exception. Is there is way to log4j in derby.
You want log4j to be visible to the same ClassLoader which contains your
procedure. If your procedure is in a jar file on the VM classpath, then
the log4j jar should be on the VM classpath. If your procedure is in a
jar file stored in the database, then you want to store the log4j jar in
the database too and wire it into the database's classpath via the
derby.database.classpath property.
Hope this helps,
-Rick
Appreciate guidance on same.
Thanks,
Anjana
*From:*Rick Hillegas [mailto:rick.hille...@gmail.com]
*Sent:* Friday, December 18, 2015 8:42 AM
*To:* derby-dev@db.apache.org
*Cc:* Anjana Prakash <anjana.prak...@actian.com>
*Subject:* Re: using log4j in user defined system procedure
On 12/17/15 6:39 AM, Anjana Prakash wrote:
Hi ,
Does user defined system procedure enable logging using log4j. or
using derby.log for logging the output from system procedure.
Appreciate any reference on same.
Thanks
Anjana
Hi Anjana,
Take a look at the derby.stream.error properties documented at
http://db.apache.org/derby/docs/10.12/ref/crefproper22250.html. Your
procedure should be able share the diagnostic log with the engine by
setting derby.stream.error.field or derby.stream.error.file or
derby.stream.error.method.
Hope this helps,
-Rick