Solved

logj4 config

Posted on 2006-06-16
4
386 Views
Last Modified: 2011-04-14
Hi,

How do i setup  logj4 config for my jsp project so that i can write to catalina.out from the jsp project?

0
Comment
Question by:komlaaa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 4

Expert Comment

by:Tol_cv
ID: 16919330
Hi,
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.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
log4j.appender.CONSOLE.layout.ConversionPattern=%c %-5p %d [%t] - %m%n


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.ConsoleAppender">
    <param name="Target" value="System.out"/>
    <layout class="org.apache.log4j.PatternLayout">
      <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).

 

0
 

Author Comment

by:komlaaa
ID: 16920790
but don't see how this bound with a specifica webapp
0
 
LVL 4

Accepted Solution

by:
Tol_cv earned 250 total points
ID: 16921014

 to bound with a specific application.
put log4j.properties under /webapps/<application>/classes

http://www.onjava.com/pub/a/onjava/2002/08/07/log4j.html?page=1
0
 
LVL 3

Expert Comment

by:ss_p
ID: 16992804
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.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Building a cohesive image for your brand is vital to making an impression on consumers. When the economy is tough, brands do better than unbranded  products. This can have a huge impact on your long-term profits, as the economy goes up and down.
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question