以下是我的log4j.properties文件log4j.rootLogger = INFO,控制台,stdout
# CONSOLE is set to be a ConsoleAppender.
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=[%t] %-5p %c %x - %m%n
log4j.logger.com.tcs=DEBUG
log4j.logger.org.springframework=INFO
#log4j.rootLogger=INFO, ROLLOVERFILE, STDOUT,DEBUG
### Direct log4j properties to STDOUT ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
# Configuration File
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.File=$\{java.io.tmpdir\}/log4j-test.log
log4j.appender.FILE.Append=true
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
在/ src / main / resources /
中我的是基于Job-Scheduler的批处理作业。当我从腻子手动运行批处理时,将打印日志。但是,在运行调度程序时,不会打印日志。仅休眠查询被打印。
我得到的第一行错误是:
log4j:ERROR Could not instantiate class [com.sos.JSHelper.Logging.JobSchedulerLog4JAppender]. java.lang.ClassNotFoundException: com.sos.JSHelper.Logging.JobSchedulerLog4JAppender at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:264) at org.apache.log4j.helpers.Loader.loadClass(Loader.java:178) at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:319) at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:120) at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:629) at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:612) at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:509) at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:415) at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:441) at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:470) at org.apache.log4j.LogManager.<clinit>(LogManager.java:122) at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:63) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:301) at com.tcs.telecom.tib.ibgateway.email.service.impl.EmailProcessor.<clinit>(EmailProcessor.java:13) log4j:ERROR Could not instantiate appender named "stdout". log4j:WARN No appenders could be found for logger (com.tcs.telecom.tib.ibgateway.email.service.impl.EmailProcessor). log4j:WARN Please initialize the log4j system properly.
请提出前进的方向。