Solved

logj4 config

Posted on 2006-06-16
4
363 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
  • 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
What is Backup? Backup software creates one or more copies of the data on your digital devices in case your original data is lost or damaged. Different backup solutions protect different kinds of data and different combinations of devices. For e…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now