logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Erskine <michael.ersk...@ketech.com>
Subject RE: Can custom appender override the log4j.xml configuration
Date Tue, 19 Aug 2008 08:19:46 GMT
Hi Aneez,

> 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

How about removing all appenders from the root logger? Or is that not what you want to achieve?
Remember that the loggers are hierarchical.

> 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.

You can programmatically set the logging level of your appender.

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

If you don't want log4j to avoid the default initialization procedure you can set the log4j.defaultInitOverrride
system property to anything other than "false".

Regards,
Michael Erskine.


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


Mime
View raw message