I am trying to package 2 projects (ExampleWeb.war and ExampleEJb.jar) in a single EAR file. Every thing works fine except the logging thing. There is no error, but even log messages are not displayed on Glassfish server. not console no where. Here are the contents of my ear file
Example.ear
ExampleWeb.war
ExampleEJB.jar
lib
log4j.properties
slf4j-api-1.7.12.jar
slf4j-log4j12-1.7.12.jar
log4j-1.2.17.jar
META-INF
application.xml
Contents of the application.xml are as follows
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://ift.tt/ra1lAU" xmlns="http://ift.tt/nSRXKP" xmlns:application="http://ift.tt/W0LURl" xsi:schemaLocation="http://ift.tt/nSRXKP http://ift.tt/1evQWgx" id="Application_ID" version="6">
<display-name>Example</display-name>
<module>
<web>
<web-uri>ExampleWeb.war</web-uri>
<context-root>/</context-root>
</web>
</module>
<module>
<ejb>ExampleEJB.jar</ejb>
</module>
<library-directory>lib</library-directory>
</application>
Please note I am able to call an EJB from web project using its remote interface and that hello method successfully write a message to console, using System.out.println("hello"); how ever there is nothing happening for log.info("hello from log");
here is how I initialized the log object
//import statement
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//variable initialization
private static final Logger log = LoggerFactory.getLogger(HelloFacade.class);
Here are the contents of log4j.properties file
# Root logger option
log4j.rootLogger=FILE,console
# ------------- Console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=[%d{ISO8601}]%5p%6.6r[%t]%x - %C.%M(%F:%L) - %m%n
log4j.appender.console.Threshold=INFO
# ---------------- File
log4j.appender.FILE=org.apache.log4j.RollingFileAppender
log4j.appender.FILE.File=${com.sun.aas.instanceRoot}/logs/log4j.log
# Archive log files (one backup file here)
log4j.appender.FILE.MaxBackupIndex=2
# Control the maximum log file size
log4j.appender.FILE.MaxFileSize=1000KB
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=[%d{ISO8601}]%5p%6.6r[%t]%x - %C.%M(%F:%L) - %m%n
log4j.appender.FILE.Threshold=INFO
Point to be noted
- There is no
slf4*.jarcan be found inGlassFishexcept with in application deployed folder. - There is no other
log4j.propertiesinGlassFishexcept with in application deployed folder.
I have tried lot of things but unable to figure out the logging thing Please help me to fix it.
Multiple test I have ran multiple test where I have removed jar files and placed them in ear's lib folder, kept the log4j.properties file in almost every folder of EAR file (rootfolder, classes folder, lib folder, META-INFO folder) but it has no impact at all, No error and no logging.
I would be really amazed if someone does not know how to achieve this (logging, EAR[with multiple jar and war files], and Glassfish)
Aucun commentaire:
Enregistrer un commentaire