Hi

I am writing a custom JDBC appender for log4j for my application. I want this custom appender NOT to be affected in any way by the loggign levels / appenders in the application log4j.xml file.

The custom Logger instance has only the one appender (the custom JDBC appender which I wrote). It has no console appender etc. But, when logging happens, log statements get printed on the server console and also in the application log files. I should mention that the application log4j.xml file does have the console and file appender.

I initialise the Logger instance as follows:



   Logger customLogger = Logger.getLogger("myCustomLogger");

   / / remove all appenders associated with customLogger
   customLogger.removeAllAppenders();

   // add JDBCAppenderService to customLogger
customLogger .addAppender(new JDBCAppenderService(ds)); //ds is the datasource name

<<


Now, I use customLogger to log the information as follows:


customLogger.info(logObject)  //logObject contains the data to be logged
<<



I want customLogger to remained unaffected by the settings in the log4j.xml file. So, if the logging level in log4j.xml is set to OFF, I still want the JDBC appneder to work i.e log data in the database.

Please let me know if there any way to achieve this ?? Or does the log4j.xml configuration overrides the settings in the class files ??

Thanks and Regards,

Aneez Backer


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to