これはディレクトリ内の私のlog4j.properties
ファイルですWEB-INF/classes
:
#SET LEVEL of ROOT-LOGGER, you will like to have Debug in local, but in prod you may just want WARN and ABOVE. This setting is done here!
log4j.rootLogger=all, stdout, R
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# Pattern to output the caller's file name and line number. (basically, format of log)
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
# THIS IS WHERE YOU WILL HAVE ALL THE LOG WRITTEN
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=/Users/miranda_zhang/Documents/workspace/cloud_demo_3/log/speedtest.log
# Maximum size of log file, usually we keep 10MB
log4j.appender.R.MaxFileSize=100KB
# Keep one backup file, usually we keep 10
log4j.appender.R.MaxBackupIndex=1
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
Java クラスには次のようなものがあります。
import org.quartz.Job;
import org.apache.log4j.Logger;
public class collectSpeedtestDataJob implements Job {
private static Logger logger = Logger.getLogger(collectSpeedtestDataJob.class);
public void execute(JobExecutionContext arg0) throws JobExecutionException {
try {
} catch (Exception e) {
logger.error(e);
}
}
}
しかし、ファイルには何も記録されません/Users/miranda_zhang/Documents/workspace/cloud_demo_3/log/speedtest.log
Consoleに表示されるメッセージは次のとおりです。
Apr 7, 2013 4:24:47 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java
Apr 7, 2013 4:24:47 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:demo_3' did not find a matching property.
Apr 7, 2013 4:24:47 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Apr 7, 2013 4:24:47 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Apr 7, 2013 4:24:47 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1993 ms
Apr 7, 2013 4:24:47 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Apr 7, 2013 4:24:47 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.19
Apr 7, 2013 4:25:02 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: urn:www.jenkov.com/projects/prizetags is already defined
Apr 7, 2013 4:25:02 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: urn:www.jenkov.com/projects/prizetags is already defined
Apr 7, 2013 4:25:02 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: urn:www.jenkov.com/projects/prizetags is already defined
Apr 7, 2013 4:25:02 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: urn:www.jenkov.com/projects/prizetags is already defined
Apr 7, 2013 4:25:02 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: urn:www.jenkov.com/projects/prizetags is already defined
Apr 7, 2013 4:25:02 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: urn:www.jenkov.com/projects/prizetags is already defined
Apr 7, 2013 4:25:02 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: urn:www.jenkov.com/projects/prizetags is already defined
Apr 7, 2013 4:25:02 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: urn:www.jenkov.com/projects/prizetags is already defined
Apr 7, 2013 4:25:02 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: urn:www.jenkov.com/projects/prizetags is already defined
Apr 7, 2013 4:25:02 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: urn:www.jenkov.com/projects/prizetags is already defined
Apr 7, 2013 4:25:02 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: urn:www.jenkov.com/projects/prizetags is already defined
log4j:WARN No appenders could be found for logger (org.quartz.impl.StdSchedulerFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Apr 7, 2013 4:25:03 PM com.sun.jersey.api.core.PackagesResourceConfig init
INFO: Scanning for root resource and provider classes in the packages:
rest.handler
Apr 7, 2013 4:25:03 PM com.sun.jersey.api.core.ScanningResourceConfig logClasses
Apr 7, 2013 4:25:03 PM com.sun.jersey.api.core.ScanningResourceConfig init
INFO: No provider classes found.
Apr 7, 2013 4:25:03 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.12 02/15/2012 04:51 PM'
Apr 7, 2013 4:25:06 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: urn:www.jenkov.com/projects/prizetags is already defined
Apr 7, 2013 4:25:06 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: urn:www.jenkov.com/projects/prizetags is already defined
Apr 7, 2013 4:25:06 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: urn:www.jenkov.com/projects/prizetags is already defined
Apr 7, 2013 4:25:06 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: urn:www.jenkov.com/projects/prizetags is already defined
Apr 7, 2013 4:25:06 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: urn:www.jenkov.com/projects/prizetags is already defined
Apr 7, 2013 4:25:06 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: urn:www.jenkov.com/projects/prizetags is already defined
Apr 7, 2013 4:25:06 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: urn:www.jenkov.com/projects/prizetags is already defined
Apr 7, 2013 4:25:06 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: urn:www.jenkov.com/projects/prizetags is already defined
Apr 7, 2013 4:25:06 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: urn:www.jenkov.com/projects/prizetags is already defined
Apr 7, 2013 4:25:06 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: urn:www.jenkov.com/projects/prizetags is already defined
Apr 7, 2013 4:25:06 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: urn:www.jenkov.com/projects/prizetags is already defined
Apr 7, 2013 4:25:07 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Apr 7, 2013 4:25:07 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Apr 7, 2013 4:25:07 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 19119 ms
-Dlog4j.debug=true
Eclipse で VM 引数として追加しました。
デバッグするために次のことを試しました。
public void execute(JobExecutionContext arg0) throws JobExecutionException {
logger.info("Log - collectSpeedtestDataJob");
System.out.println("info logged");
try {
DB.executeUpdate(speedtest());
} catch (Exception e) {
logger.error(e);
}
}
Consoleでは、これが出力されているのを確認できますが、ログ ファイルには何も表示されません。
log4j:WARN No appenders could be found for logger (org.quartz.impl.StdSchedulerFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
info logged