Reputation: 2080
I'm using Eclipse with an external Tomcat ("use tomcat installation, takes control of tomcat").
Our application logs are currently configured with log4j
using a FileAppender
.
Is it possible to redirect the log messages to the eclipse console without using a ConsoleAppender
?
I tried it with a ConsoleAppender
and it works fine, but then I have to create an extra log4j.properties
file for development and production mode (as we don't want console logs on stage or production systems).
Upvotes: 0
Views: 551
Reputation: 280
One way is to write your custom appender using code itself and attache that appender to root logger.
// if it is not production then only execute this mode
ConsoleAppender console = new ConsoleAppender(); //create appender
//configure the appender
String PATTERN = "%d [%p|%c|%C{1}] %m%n";
console.setLayout(new PatternLayout(PATTERN));
console.setThreshold(Level.FATAL);
console.activateOptions();
//add appender to any Logger (here is root)
Logger.getRootLogger().addAppender(console);
I don't know your application code but you can patch this code somewhere in your code and logically fix this problem. P.S. Again this is just a logical solution. Other way is already known to you that is log4j property file.
Upvotes: 2