Hi All, A log4j newbie handling a bigger task .. This is my problem 
Hope somebody has got some solution for this. 

We have a web application as well as a java application. Both are big enough
. But since both are managing the same business around 3 to 4 ear files are
used in common for both the applications. Since we wanted to classify the
loggers based on the application we have decided to have unique
log.properties file. The following are the configurations in the
log.properties file 

for web application
log4j.threshold=ALL 
log4j.rootLogger=ALL,INFO_APPENDER,ERROR_APPENDER,DEBUG_APPENDER 
log4j.appender.DEBUG_APPENDER=org.apache.log4j.RollingFileAppender 
log4j.appender.DEBUG_APPENDER.MaxBackupIndex=50 
log4j.appender.DEBUG_APPENDER.MaxFileSize=10MB 
log4j.appender.DEBUG_APPENDER.file=data/tda/logs/Logger_Debug_Web.txt 
log4j.appender.DEBUG_APPENDER.layout=org.apache.log4j.PatternLayout 
log4j.appender.DEBUG_APPENDER.Threshold=DEBUG 

for java application
log4j.threshold=ALL 
log4j.rootLogger=ALL,INFO_APPENDER,ERROR_APPENDER,DEBUG_APPENDER 
log4j.appender.DEBUG_APPENDER=org.apache.log4j.RollingFileAppender 
log4j.appender.DEBUG_APPENDER.MaxBackupIndex=50 
log4j.appender.DEBUG_APPENDER.MaxFileSize=10MB 
log4j.appender.DEBUG_APPENDER.file=data/tda/logs/Logger_Debug_Java.txt 
log4j.appender.DEBUG_APPENDER.layout=org.apache.log4j.PatternLayout 
log4j.appender.DEBUG_APPENDER.Threshold=DEBUG 

The following is the customized log manager class which we have written 
public class LogManager { 
        String className; 
        Logger objLog; 

        static { 
                InputStream logprops = LogManager.class.getClassLoader() 
                               
.getResourceAsStream("path/to/log.properties"); 
                try { 
                        Properties prop = new Properties(); 
                        prop.load(logProps); 
                        PropertyConfigurator.configure(prop); 
                } catch (Exception e) { 
                        System.out.println("error in  LogManager" +
e.getMessage()); 
                } 
        } 

        public LogManager(String className) { 
                this.className = className; 
                objLog = Logger.getLogger(this.className); 
        } 

        public void logMessage(String strLevel, String Message) { 
                if (strLevel.equals("DEBUG")) { 
                        objLog.log(Level.DEBUG, Message); 
                } else if (strLevel.equals("INFO")) { 
                        objLog.log(Level.INFO, Message); 
                } else if (strLevel.equals("WARN")) { 
                        objLog.log(Level.WARN, Message); 
                } else if (strLevel.equals("ERROR")) { 
                        objLog.log(Level.ERROR, Message); 
                } 
        } 
} 

And in each class files we have called the logmanager like 

private static final LogManager logMgr = new
LogManager(QueueListener.class.getName()); 
logMgr.logMessage("INFO","QueueListening starts."); 

Now our problem is that most of the times the messages in the
Logger_Debug_Java.txt is routed to Logger_Debug_Web.txt once a class which
is common for both application executes. Then the thread or control does not
go back to the Logger_Debug_Java.txt file. Please give me a solution for
this problem 

Kannan.S 
-- 
View this message in context: 
http://www.nabble.com/Logging-done-in-the-wrong-files-tp25411329p25411329.html
Sent from the Log4j - Users mailing list archive at Nabble.com.


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

Reply via email to