Boa Tarde Pessoal,
É o seguinte: fiz alguns testes com o Log4J através do seu arquivo de configuração (Log4J.properties) e consegui que ele salvasse o log no banco,porém, como tenho um arquivo de configuração JNDI que utilizo para as configurações do JPA/Hibernate e futuramente para inserção do Spring Security em meu projeto, gostaria de nas configuração do arquivo de log4j tão acessasse essa conexão existe. Tentei de algumas formas,mas n obtive exito.
Arquivo context.xml (JNDI)
<?xml version='1.0' encoding='utf-8'?><Resource
name="jdbc/curso"
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/curso"
username="usuario"
password="senha"
maxActive="100"
maxIdle="30"
maxWait="10000" />
Arquivo Log4J.properties
Define the root logger with appender file
log4j.rootLogger = INFO, jdbc
Define the DB appender
#log4j.appender.jdbc=org.apache.log4j.extended.jdbc.JDBCAppender
#log4j.appender.jdbc=org.apache.log4j.jdbc.JDBCAppender
log4j.appender.jdbc.datasource=java:jdbc/cursocompec
Set JDBC URL
#log4j.appender.DB.URL=jdbc:mysql://localhost:3306/curso
Set Database Driver
#log4j.appender.DB.driver=com.mysql.jdbc.Driver
Set database user name and password
#log4j.appender.DB.user=usuario
#log4j.appender.DB.password=senha
Set the SQL statement to be executed.
log4j.appender.jdbc.sql=INSERT INTO LOGS VALUES(’%X{USER}’,’%d{yyyy-MM-dd HH:mm:ss.SSS}’,’%C’,’%p’,’%m’)
Define the layout for file appender
log4j.appender.jdbc.layout=org.apache.log4j.PatternLayout
O erro basicamente é esse
log4j:ERROR Could not find value for key log4j.appender.jdbc
log4j:ERROR Could not instantiate appender named “jdbc”.
log4j:WARN No appenders could be found for logger (org.hibernate.annotations.common.Version).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Qualquer pista é bem-vinda para que eu continue procurando a solução