logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From AB_Kadri <abdouka...@gmail.com>
Subject DataBase Logging using Log4j problem
Date Tue, 24 Aug 2010 19:44:42 GMT

HI all ,
I am very grateful in advance for any help for suggestion
I want to use the Database logging using Log4j.
I am using the following log4j.properties file 
-------------------------------------------------------------
log4j.rootLogger = info, DB

# project specific logger configuration
log4j.logger.test=info, DB
log4j.additivity.test=true

# Define the DB appender
log4j.appender.DB=org.apache.log4j.jdbc.JDBCAppender

# Set JDBC URL
log4j.appender.DB.URL=jdbc:sqlserver://db22:3643

# Set Database Driver
log4j.appender.DB.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver

# Set database user name and password
log4j.appender.DB.user=dbLogger
log4j.appender.DB.password=123456789

# Set the SQL statement to be executed.
log4j.appender.DB.sql=INSERT INTO
DB_LOGGING(SYS_CODE,USERID,TIMESTMP,LOGGER_CLASS,LOGGER_LEVEL,LOGGER_MESSAGE)
VALUES('E','%X{userid}',getDate(),'%C','%p','%m')
-----------------------------------------------------

the issue I am facing here that is logs fine to the DB BUT when I have a
quote (') in the logging Message (%m), and Database will insert the above
statment with quote in the message I'll have the following error


[8/24/10 15:40:41:220 EDT] 00000032 SystemErr     R log4j:ERROR Failed to
excute sql
[8/24/10 15:40:41:220 EDT] 00000032 SystemErr     R
com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near
'https:'.
[8/24/10 15:40:41:220 EDT] 00000032 SystemErr     R 	at
com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown
Source)
[8/24/10 15:40:41:220 EDT] 00000032 SystemErr     R 	at
com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown
Source)
[8/24/10 15:40:41:220 EDT] 00000032 SystemErr     R 	at
com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(Unknown
Source)
[8/24/10 15:40:41:220 EDT] 00000032 SystemErr     R 	at
com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(Unknown
Source)
[8/24/10 15:40:41:220 EDT] 00000032 SystemErr     R 	at
com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
[8/24/10 15:40:41:220 EDT] 00000032 SystemErr     R 	at
com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown
Source)
[8/24/10 15:40:41:220 EDT] 00000032 SystemErr     R 	at
com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(Unknown
Source)
[8/24/10 15:40:41:220 EDT] 00000032 SystemErr     R 	at
com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(Unknown
Source)
[8/24/10 15:40:41:220 EDT] 00000032 SystemErr     R 	at
com.microsoft.sqlserver.jdbc.SQLServerStatement.executeUpdate(Unknown
Source)
[8/24/10 15:40:41:220 EDT] 00000032 SystemErr     R 	at
org.apache.log4j.jdbc.JDBCAppender.execute(JDBCAppender.java:178)
[8/24/10 15:40:41:220 EDT] 00000032 SystemErr     R 	at
org.apache.log4j.jdbc.JDBCAppender.flushBuffer(JDBCAppender.java:250)
[8/24/10 15:40:41:220 EDT] 00000032 SystemErr     R 	at
org.apache.log4j.jdbc.JDBCAppender.append(JDBCAppender.java:146)
[8/24/10 15:40:41:220 EDT] 00000032 SystemErr     R 	at
org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:230)
[8/24/10 15:40:41:220 EDT] 00000032 SystemErr     R 	at
org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:65)
[8/24/10 15:40:41:220 EDT] 00000032 SystemErr     R 	at
org.apache.log4j.Category.callAppenders(Category.java:203)
[8/24/10 15:40:41:220 EDT] 00000032 SystemErr     R 	at
org.apache.log4j.Category.forcedLog(Category.java:388)
[8/24/10 15:40:41:220 EDT] 00000032 SystemErr     R 	at
org.apache.log4j.Category.error(Category.java:319)
.....


-- 
View this message in context: http://old.nabble.com/DataBase-Logging-using-Log4j-problem-tp29525713p29525713.html
Sent from the Log4j - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message