I am writing a class in my application for insert logs to oracle database. I have used log4j. I made these configurations:
<appender name="DB" class="org.apache.log4j.jdbc.JDBCAppender">
<param name="URL" value="jdbc:oracle:thin:@10.60.2.8:1521:dbName"/>
<param name="Driver" value="oracle.jdbc.driver.OracleDriver"/>
<param name="User" value="test"/>
<param name="Password" value="test"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="INSERT INTO LOG_OVERLOADREQUEST VALUES('%x{today}','%x {currentRequestURI}','%x {UserName}','%x {URI}','%x {method}','%x {CPULoad}','%x {timeSpent}','%x {lastCPULoad}','%x {firstFreeMemory}','%x {lastFreeMemory}','%x {appID}','%x {sessionId}')"/>
</layout>
</appender>
here are the codes in my class:
private Logger overLoadRequestDB=Logger.getLogger("log4j.rootLogger");
Timestamp today = new Timestamp(System.currentTimeMillis());
MDC.put("today", today);
MDC.put("currentRequestURI", currentRequestURI);
MDC.put("UserName", "Test");
MDC.put("URI", currentRequestURI);
MDC.put("method", "test");
MDC.put("CPULoad",1234);
MDC.put("timeSpent", 1234);
MDC.put("lastCPULoad", 123);
MDC.put("firstFreeMemory", 123);
MDC.put("lastFreeMemory", 123);
MDC.put("appID", 1);
MDC.put("sessionId","123");
overLoadRequestDB.debug("test");
overLoadRequestDB.info("test");
when I run the application I face this error: ORA-01858: a non-numeric character was found where a numeric was expected
I think ths is something related to date, but I did everything I could I don't know what the problem is.
Aucun commentaire:
Enregistrer un commentaire