komlaaa
asked on
logj4 config
Hi,
How do i setup logj4 config for my jsp project so that i can write to catalina.out from the jsp project?
How do i setup logj4 config for my jsp project so that i can write to catalina.out from the jsp project?
ASKER
but don't see how this bound with a specifica webapp
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you have to put the log4j.properties file in WEB-INF/classes folder.
When the server starts,
It loads all the classes in classes folder, and if log4.properties file is present in classes folder. The log4j property gets set for that particular appliaction.
When the server starts,
It loads all the classes in classes folder, and if log4.properties file is present in classes folder. The log4j property gets set for that particular appliaction.
everthing sended to console is written in catalina.out.
log4j.properties configuration file:
log4j.debug=true
log4j.rootLogger=DEBUG, CONSOLE # your log level ... that will write all logs in catalina
log4j.appender.CONSOLE=org
log4j.appender.CONSOLE.lay
log4j.appender.CONSOLE.lay
log4j.appender.CONSOLE.lay
or in xml configuration:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="console" class="org.apache.log4j.Co
<param name="Target" value="System.out"/>
<layout class="org.apache.log4j.Pa
<param name="ConversionPattern" value="%-5p %c{1} - %m%n"/>
</layout>
</appender>
<root>
<priority value ="debug" />
<appender-ref ref="console" />
</root>
</log4j:configuration>
a useful link http://logging.apache.org/log4j/docs/manual.html ( it describes how can you configurate log4j for tomcat etc).