It is useful to enable log4j to receive VRaptor messages when loading and executing web application. VRaptor uses log4j to output a lot of information about components, parameters, logics, interceptors etc which helps you to debug the application.
VRaptor supports all log4j output levels: TRACE, DEBUG, INFO, WARN, ERROR and FATAL.
In order to enable log4j you must to put the log4j-1.2.12.jar (or newer) into the WEB-INF/lib folder (if you are in doubt about the directory structure, please download the blank-project).
You must also create a log4j.xml file to your classpath with the following content:
<log4j:configuration> <appender name="stdout" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %5p [%-20c{1}] %m%n"/> </layout> </appender> <category name="org.vraptor"> <priority value="TRACE"/> <appender-ref ref="stdout"/> </category> </log4j:configuration>
That's all you have to do. You enabled log4j with trace level for any subpackage of org.vraptor and should now get every possible VRaptor message regarding your web application.
In order to use a different log level (maybe TRACE is to much info) just change the priority value in log4j.xml file. For example, if you use priority value="INFO" you will only receive info, warn, error and fatal messages. Any trace or debug message will be omitted.