我开始使用 Struts2。使用 sl4j 登录 HelloWorld 示例。没有创建日志文件,控制台中也没有任何内容。
有人帮助我我做错了什么?
下面是我的项目结构。
属性文件
# Default Logging Level is DEBUG. levels: DEBUG < INFO < WARN < ERROR < FATAL OR ALL. Its only appender to FILE.
# Root logger option
log4j.rootLogger = ALL, FILE, stdout
# Define the file appender
# log4j.appender.FILE=org.apache.log4j.FileAppender
# backup the log files when they reach a certain size
log4j.appender.FILE=org.apache.log4j.RollingFileAppender
# Set the name of the file
log4j.appender.FILE.File=C:\\test.log
# Specify the log file size and max backup index.
log4j.appender.Logger.MaxFileSize=5mb
log4j.appender.Logger.MaxBackupIndex=20
# Set the threshold to debug mode
log4j.appender.FILE.Threshold=DEBUG
# Set the append to false, overwrite
log4j.appender.FILE.Append=false
# Define the layout for file appender
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.conversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
# log4j.rootLogger = ALL, FILE, stdout
# Output To Console: Direct log messages 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
信任.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<package name="default" extends="struts-default">
<action name="HelloWorld" class="vaannila.HelloWorld">
<result name="SUCCESS">/success.jsp</result>
</action>
</package>
</struts>