Solved

logj4 config

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

With the rapid rise in mobile usage, mobile devices are here to stay and have become an integral part of doing business. Here are 9 great apps for your BYOD environment.
When rebooting a vCenters 6.0 and try to connect using vSphere Client we get this issue "Invalid URL: The hostname could not parsed." When we get this error we need to do some changes in the vCenter advanced settings to fix the issue.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 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

27 Experts available now in Live!

Get 1:1 Help Now