How are you I have two java web applications in which I use log4j. The problem I have that every time I perform a deploy of any of the applications the other application's log is started to save in the log file of the last one that performs the deploy.
This is the log4j.properties file of the appweb application
log4j.rootLogger = INFO, archivog
log4j.appender.archivog = org.apache.log4j.FileAppender
log4j.appender.archivog.file = /var/log/appweb/appweb-gateway.log
log4j.appender.archivog.layout=org.apache.log4j.PatternLayout
log4j.appender.archivog.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
log4j.appender.archivog.append = false
log4j.appender.archivog.MaxFileSize=5MB
log4j.appender.archivog.MaxBackupIndex=1
This is the log4j.properties file of app 2 appweb2
log4j.rootLogger = INFO, archivo
log4j.appender.archivo = org.apache.log4j.FileAppender
log4j.appender.archivo.file = /var/log/appweb/appweb2-impl.log
log4j.appender.archivo.layout=org.apache.log4j.PatternLayout
log4j.appender.archivo.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
log4j.appender.archivo.append = false
log4j.appender.archivo.MaxFileSize=5MB
log4j.appender.archivo.MaxBackupIndex=1
The files are loaded into the appweb and appweb2 servlet applications
public void init(ServletConfig config) throws ServletException {
try {
System.out.println("Init Servlet Gateway");
String path = config.getServletContext().getRealPath(getServletInfo());
String pathlog4j = "/WEB-INF/classes/log4j.properties";
System.out.println("Patch Log4J Gateway: "+path+pathlog4j);
PropertyConfigurator.configure(path+pathlog4j);
Logger.getLogger(Initialize.class.getName()).log(Level.INFO,
"*** Start Gateway Servlet Initialized Config.. ***");
} catch (Exception e) {
Logger.getLogger(Initialize.class.getName()).log(Level.ERROR,e);
}
}
Are two different applications each with its separate log file. Some suggestion why this happens to me.
Aucun commentaire:
Enregistrer un commentaire