Can we able to create two instance of log4j in class one to write in file and another in jdbcadapter?
// one to write log in console
Logger log = Logger.getLogger(this.getClass());
// write in database within one class
Logger log1 = Logger.getLogger(this.getClass());
My jdbc adapter is
My file adapter is
I wan to Logger instance log for File anmd Logger instant log1 for jdbc.
In
log4jthere are variousAppendersavailable, with descriptive names, such asFileAppender, ConsoleAppender, SocketAppender, SyslogAppender, NTEventLogAppender and even SMTPAppender. Multiple Appenders can be attached to any Logger, so it’s possible to log the same information to multiple outputs; for example to a file locally and to a socket listener on another computer.Moreover if want to write logs to different outputs according to the level then you could try Log to appender by level.