I have a problem with log4j. I'm trying to use this for logging in a file some actions in my Rest Web Service. I am developing the web service in java with jersey framework. I am using Eclipse and a Maven Project.
I've created my MWlogs.properties and placed under src. The content of this file is:
# LOG4J daily rolling log files configuration
log4j.rootLogger=DEBUG, RollingAppender
# RollingAppender configuration
log4j.appender.RollingAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.RollingAppender.File=./logs/mobiwallet.log
log4j.appender.RollingAppender.DatePattern='.'yyyy-MM-dd
log4j.appender.RollingAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.RollingAppender.layout.ConversionPattern=[%p] %d %c %M - %m%n
Then under service package I've tried to test log4j but it's not running correctly. What I have in this class under service package is:
...
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
...
@Path("/UserActions")
public class UserActions {
static final Logger logger = Logger.getLogger(UserActions.class);
...
public MW_USER_DATA_QUERY_RESPONSE reqMWUser(InputStream userRequest){
PropertyConfigurator.configure("MWlogs.properties");
...
logger.info("Consulta de MW USER!!!!!");
return reply;
}
}
Tomcat is launching some error when I try to run the project:
log4j:ERROR Could not read configuration file [MWlogs.properties].
And when logger.info is executed Tomcat shows also the following error message:
log4j:WARN No appenders could be found for logger (service.UserActions).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info