"Carsten Hammer" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
> Hi,
> is it possible to use log4j on jboss using a jdbc appender and an entity
> bean with bean managed persistency for accessing it? Is there something
> ready to use? Is it possible to configure a jdbc appender for jboss'
> log4j by deploying a ear archive?
> Thanks in advance,
> Best regards,
> Carsten Hammer
>

Now I found out how to use the JDBCAppender in jboss3.2.x:

server/default/log4j.xml now contains the following additional entrys(I use
MSSQL2000):

<appender name="MYDBLOG" class="org.apache.log4j.jdbc.JDBCAppender">

<param name="URL"
value="jdbc:microsoft:sqlserver://localhost:1433;SelectMethod=cursor;Databas
eName=jboss"/>

<param name="Threshold" value="INFO"/>

<param name="User" value="dbuser"/>

<param name="Password" value="dbpassword"/>

<param name="Driver" value="com.microsoft.jdbc.sqlserver.SQLServerDriver"/>

<param name="sql" value="INSERT INTO
log4jlog(category,thread,message,priority,server,eventtime)
VALUES('%c','%t','%m','%-5p','localhost','%d')"/>

</appender>

<root>

<appender-ref ref="CONSOLE"/>

<appender-ref ref="FILE"/>

<appender-ref ref="MYDBLOG"/>

</root>

Before this works you have to create a table in the database:

CREATE TABLE log4jlog (eventtime varchar(80), server varchar(80), priority
varchar(80), message varchar(200), thread varchar(80), category varchar(80),
id int identity NOT NULL PRIMARY KEY);

After this you have a nice log table that you can access from inside of your
EJB´s.

Two questions remain:

1. Is it possible to let log4j automatically create the table?

2. How to do this all in a application specific way. That means deploy a
log4j.xml file within my ear archive, create the neccessary tables at
deployment time and then have full access to all interesting parts of the
log in you application. (I tried to create a CMP entity bean with the
neccessary fields to let jboss automatically create the table at deployment
time but at that moment it is to late and a missing table leads to deadly
slow performance)

Best regards,

Carsten Hammer





-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to