Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-17-2008, 01:13 PM
Member
 
Join Date: Mar 2008
Posts: 1
prakash_dev is on a distinguished road
Log4j not working properly....
log4j is not working in struts application but same code working on ejb module..

here is my log4j.xml amd appender class........


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration>
<!-- ================================= -->
<!-- Preserve trace messages in a local file -->
<!-- ================================= -->
<!-- A size based rolling appender -->
<appender name="trace" class="org.apache.log4j.FileAppender">
<param name="file" value="C:/CustomerPortal/trace.log" />
<param name="Append" value="true" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="[%d{ISO8601}] %-5p %c %m %n" />
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMin" value="TRACE"/>
<param name="LevelMax" value="DEBUG"/>
</filter>
</appender>

<!-- ================================= -->
<!-- Preserve error messages in a local file -->
<!-- ================================= -->
<appender name="error" class="org.apache.log4j.FileAppender">
<param name="file" value="C:/CustomerPortal/error.log" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="[%d{ISO8601}] %-5p %c %m %n" />
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMin" value="INFO"/>
<param name="LevelMax" value="FATAL"/>
</filter>
</appender>
<!-- ================================= -->
<!-- Preserve messages in a local file -->
<!-- ================================= -->
<appender name="FILE" class="org.apache.log4j.FileAppender">
<param name="File" value="C:/CustomerPortal/log.log"/>
<param name="MaxBackupIndex" value="3" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ISO8601} %-5p [%c] %m%n"/>
</layout>
</appender>
<!-- ============================== -->
<!-- Append messages to the console -->
<!-- ============================== -->
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
<param name="Threshold" value="INFO"/>
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%d{ISO8601} %-5p [%c{1}] %m%n"/>
</layout>
</appender>

<!-- ================ -->
<!-- Limit categories -->
<!-- ================ -->
<category name="cp.common.log">
<priority value="MY_TRACE" class="cp.common.log.Appender" />
<appender-ref ref="FILE"/>

</category>
<!-- ======================= -->
<!-- Setup the Root category -->
<!-- ======================= -->
<root>
<level value="all" />
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
<appender-ref ref="error"/>
<appender-ref ref="trace"/>

</root>
</log4j:configuration>
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package cp.common.log;

import org.apache.log4j.Category;
import org.apache.log4j.Level;

/**
*
* @author localuser
*/
public class Appender extends Level {

/** * Value of my trace level. This value is lesser than
* {@link org.apache.log4j.Priority#DEBUG_INT}
* and higher than {@link org.apache.log4j.Level#TRACE_INT}
*/
public static final int MY_TRACE_INT = DEBUG_INT - 10;
/**
* {@link Level} representing my log level
*/
public static final Level MY_TRACE = new Appender(MY_TRACE_INT, "MY_TRACE", 7);

private Category l_category = null;

/**
* Constructor
*
* @param arg0
* @param arg1
* @param arg2
*/
protected Appender(int arg0, String arg1, int arg2) {
super(arg0, arg1, arg2);
}

/**
* Checks whether sArg is "MY_TRACE" level. If yes then returns
* {@link MyTraceLevel#MY_TRACE}, else calls
* {@link MyTraceLevel#toLevel(String, Level)} passing it
* {@link Level#DEBUG} as the defaultLevel.
*
* @see Level#toLevel(java.lang.String)
* @see Level#toLevel(java.lang.String, org.apache.log4j.Level)
*
*/
public static Level toLevel(String sArg) {
if (sArg != null && sArg.toUpperCase().equals("MY_TRACE")) {
return MY_TRACE;
}
return (Level) toLevel(sArg, Level.DEBUG);
}

/**
* Checks whether val is {@link MyTraceLevel#MY_TRACE_INT}.
* If yes then returns {@link MyTraceLevel#MY_TRACE}, else calls
* {@link MyTraceLevel#toLevel(int, Level)} passing it {@link Level#DEBUG}
* as the defaultLevel
*
* @see Level#toLevel(int)
* @see Level#toLevel(int, org.apache.log4j.Level)
*
*/
public static Level toLevel(int val) {
if (val == MY_TRACE_INT) {
return MY_TRACE;
}
return (Level) toLevel(val, Level.DEBUG);
}

/**
* Checks whether val is {@link MyTraceLevel#MY_TRACE_INT}.
* If yes then returns {@link MyTraceLevel#MY_TRACE},
* else calls {@link Level#toLevel(int, org.apache.log4j.Level)}
* * @see Level#toLevel(int, org.apache.log4j.Level)
*/
public static Level toLevel(int val, Level defaultLevel) {
if (val == MY_TRACE_INT) {
return MY_TRACE;
}
return Level.toLevel(val, defaultLevel);
}

/**
* Checks whether sArg is "MY_TRACE" level.
* If yes then returns {@link MyTraceLevel#MY_TRACE}, else calls
* {@link Level#toLevel(java.lang.String, org.apache.log4j.Level)}
* * @see Level#toLevel(java.lang.String, org.apache.log4j.Level)
*/
public static Level toLevel(String sArg, Level defaultLevel) {
if (sArg != null && sArg.toUpperCase().equals("MY_TRACE")) {
return MY_TRACE;
}
return Level.toLevel(sArg, defaultLevel);
}

public void debug(Object text) {

l_category.debug(text);

}
}



please help me quick.........

thanks
dev
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regarding Log4j sidiq New To Java 0 04-07-2008 08:35 PM
log4j not working in struts Manu Web Frameworks 0 03-19-2008 03:54 PM
Log4j chakri New To Java 1 02-08-2008 11:15 PM
log4j swapna_d New To Java 5 01-21-2008 09:49 AM
how to properly express adding... paul New To Java 1 08-07-2007 06:08 AM


All times are GMT +3. The time now is 10:51 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org