在 default\conf\jboss-log4j.xml 文件中,
增加如下语句:
<appender name="log_CONSOLE" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
<param name="Threshold" value="DEBUG"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
</layout>
</appender>
<appender name="log_FILE" class="org.jboss.logging.appender.RollingFileAppender">
<!--此处定义日志文件名-->
<param name="File" value="${jboss.server.home.dir}/log/myname-security.log"/>
<param name="Append" value="true"/>
<param name="MaxFileSize" value="3000KB"/>
<param name="MaxBackupIndex" value="1"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%c{1}] %m%n: "/>
</layout>
</appender>
<!--此处定义在哪些包里面使用日志-->
<category name="com.myname.security">
<priority value="TRACE" />
<appender-ref ref="log_CONSOLE" />
<appender-ref ref="log_FILE"/>
</category>