U
Uli Kunkel
I'm logging hibernate HQL queries to a log file (file1.log).
The problem is I have a thread which logs to a different file (file2.log).
So I want to change appenders at runtime so that 2 different threads
would simultaniously write hibernate loggs to a different file.
I'm not sure if this will work because I don't know how log4j getLogger
is implemented (if it is singleton or not).
The idea is to call the code below as needed.
Does anyone have any suggestions about this?
Thanks in advance.
-------------------------------------------------------
public static void setHibernateLogAppender(Logger logger) {
Logger.getLogger("org.hibernate.SQL").removeAllAppenders();
while(logger.getAllAppenders().hasMoreElements())
Logger.getLogger("org.hibernate.SQL").addAppender((Appender)logger.getAllAppenders().nextElement());
}
------------------------------------------------------
The problem is I have a thread which logs to a different file (file2.log).
So I want to change appenders at runtime so that 2 different threads
would simultaniously write hibernate loggs to a different file.
I'm not sure if this will work because I don't know how log4j getLogger
is implemented (if it is singleton or not).
The idea is to call the code below as needed.
Does anyone have any suggestions about this?
Thanks in advance.
-------------------------------------------------------
public static void setHibernateLogAppender(Logger logger) {
Logger.getLogger("org.hibernate.SQL").removeAllAppenders();
while(logger.getAllAppenders().hasMoreElements())
Logger.getLogger("org.hibernate.SQL").addAppender((Appender)logger.getAllAppenders().nextElement());
}
------------------------------------------------------