GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Tech FAQs  >  Programming  >  Java
Go To First  |  Previous Question  |  Next Question 
 Java  |  Question 2 of 928    Print  
How to use lo4j in wsad as a degugger? Can anyone can give me a simple example ?

  
Total Answers and Comments: 2 Last Update: July 25, 2005   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
July 25, 2005 05:32:05   #1  
Rit        

RE: How to use lo4j in wsad as a degugger? Can anyone can give me a simple example ?
run this file i think result will itself explain you the use of LOG4J. otherwise mail me ritesh.patni@gmail.com :-
package com.banking.log4j;
import org.apache.log4j.*;

import com.lnt.banking.constant.ConstantIf;
public class TestLogging {
static Logger cat Logger.getLogger(ConstantIf.LOG4JKEY);
static Logger cat1 Logger.getLogger( com.foo );
//static Logger cat1 (Logger) Logger.getInstance(TestLogging.class.getName());
static
{
BasicConfigurator.configure();
try {
cat.setLevel(Level.ERROR);
cat1.setLevel(Level.DEBUG);
cat1.addAppender(new RollingFileAppender(new HTMLLayout() ConstantIf.dest1));
} catch (Exception e) {
cat.fatal( The Exception is : e);
}
finally
{
cat1.fatal( The Exception is : );
cat.fatal( The Exception is : );
}
}
public static void main(String[] args) {
System.out.println(args.length);
cat1.debug( Start of the MAIN()-- CAT1 );
cat1.info( This is Testing for the INFO method()-- CAT1 );
cat1.warn( This is Testing for the WARN method()-- CAT1 );
cat1.error( This is Testing for the ERROR method()-- CAT1 );
cat1.fatal( This is Testing for the fatal method()-- CAT1 );
cat.debug( Start of the MAIN() );
cat.info( This is Testing for the INFO method() );
cat.warn( This is Testing for the WARN method() );
cat.error( This is Testing for the ERROR method() );
cat.fatal( This is Testing for the fatal method() );
new TestLogging().init();
}
public void init(){
java.util.Properties prop System.getProperties();
java.util.Enumeration enum prop.propertyNames();

cat.info( *******System Enviroment As seen by Java **** );
cat.debug( ******Format : PROPERTY + VALUE ***** );
try
{
throw new Exception( exception );
}
catch(Exception e)
{
cat.error( This is new Error e);
}
finally
{
cat1.info( You Are at the end of the INIT() of the TestLogging class );
cat.info( You Are at the end of the INIT() of the TestLogging class );
}

}
}

 
Is this answer useful? Yes | No
July 25, 2005 07:04:43   #2  
Muhammad Sajjad Awan        

RE: How to use lo4j in wsad as a degugger? Can anyone can give me a simple example ?
there are few step to use Log4J in you java code.
1- creat a file name log.properties with following text
log4j.rootLogger debug stdout R

log4j.appender.stdout org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout org.apache.log4j.PatternLayout

# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern 5p d{dd MMM yyyy HH:mm:ss SSS} ( F: L) - m n

log4j.appender.R org.apache.log4j.RollingFileAppender
log4j.appender.R.File c:out.log

log4j.appender.R.MaxFileSize 1024KB
# Keep one backup file
log4j.appender.R.MaxBackupIndex 1

log4j.appender.R.layout org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern 5p d{dd MMM yyyy HH:mm:ss SSS} ( F: L) - m n


2- import package import org.apache.log4j.*;
3- PropertyConfigurator.configure(log.properties file path shuld be here);-
4- logger Logger.getLogger(ClassName.class);
5- logger.debug( any message you want to display );

 
Is this answer useful? Yes | No

 Related Questions

Latest Answer : there are few step to use Log4J in you java code. 1- creat a file name log.properties with following text log4j.rootLogger=debug, stdout, R  log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout  # ...


give me anssss 
Latest Answer : jsp : JSP Contain MVCServelt : n-tier Architerby nirmala ...
Read Answers (2) | Asked by : bipin

Latest Answer : hai,sun will release many versions of java and in each version they are including many new APIs in the same way they are removing some methods which were there in the prev versions.eg: Thread class --stop(). ...
Read Answers (2) | Asked by : shekhar

please give me answer ,if know with code also 
Latest Answer : We need to consider different paramaters when chossing between the drivers. The following summarizes the types of drivers to use in different situations. Performance with stored procedures: Type 2Scalability: Type 3, Type 4Transparent Application Failover: ...
Read Answers (4) | Asked by : siddu

I have a problem to geting and seting date format in jdbc,plz give me right solution for this problem.
Read Answers (3) | Asked by : ranilparmar

Latest Answer : JVM: Java Virtual Machine-It is beck-end software of java which support java program execution. Just like an Operating System (but JVM is not OS) it provides process/memory management while executing a java program. It is nbot a particular executable ...
Read Answers (2) | Asked by : srikanth.m

What is the difference between equals() method and == operator.when we use 2 same strings for finding of whether both strings r equal or not by using these two,it will give same answers.i.e true and true.so what is the main defference between equals() and ==.
Read Answers (2) | Asked by : haritha

Can give answer to the folloing questionQuestion 2You are in charge of implementing a Grand Prix Car Racing Results system for a sports magazine, to be used for entering and processing data concerning each Formula 1 Grand Prix that has been run in the season.As you know, each driver is part of the team, and has a number. At the end of each race, the driver who arrived first is assigned 9 points, and the following five drivers receive 6,4,3,2 and 1 point each. Drivers who come in after the sixth
View Question | Asked by : hari2
Tags : RDBMS

A) 0 to 215-1 B) 0 to 216-1 C) 0 to 215  D) 0 to 216   
Latest Answer : the range of char is 0 to 2^16 -1http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html) char range is 65535 that is equivalent to 2^16 -1 so answer B is right ...


 Sponsored Links

 
Related Articles

Service Oriented Java Business Integration Review

Service Oriented Java Business Integration Review Introduction If you ve read through the texts which give you an introduction to SOA or Web Services you will often find them to be quite frustrating and the reason for this is because they spend too much time referencing business processes which are
 

Concepts of Object-Oriented Programming

Object Oriented JavaScript In this chapter you ll learn about OOP Object Oriented Programming and how it relates to JavaScript As an ASP NET developer you probably have some experience working with objects and you may even be familiar with concepts such as inheritance However unless you re already a
 

Java and Client Server Models

Java and Client Server Models The Role of Client Servers on the Web Client server models provide the essential mechanisms for working with the Internet In fact most of the World Wide Web is built according to this paradigm In client server models the web browsers run by millions of users are the cli
 

Simple Tips to follow Before You Quit Job

You don’t have to force yourself to work in a company you don’t like. You can easily transfer to another company or just quit and take it easy until a new opportunity comes. Working in a company that you are not at ease will only give you stress and could be dangerous for your he
 

SQL Programming

SQL Programming Overview Anybody who has done something for a long time has probably wanted to change how things work at some point or another. A worker at a mill might have found a more efficient way of cutting logs, or a mathematics teacher might have had a hand in changing a school’s al
 

WinRunner Programming Concepts

If you want to create WinRunner scripts that are highly efficient, there are important programming concepts that you will want to become familiar with. Understanding these concepts will provide you with a large number of key benefits. In addition to understanding these concepts, you must also learn
 

Programming Languages Certification

IT Certification programs have several options that will offer you the best knowledge.  By learning everything that you need to know about information technology you will be able to open new doors to your career and personal business desires.  IT Certification offers several vari
 

Using UML with Java

Using UML with Java While Java is not a new language its application for the development of embedded systems is quite new Developers are beginning to take a second look at modeling languages such as UML and many feel it can be a powerful tool in their development arsenal mosgoogle center Introductio
 

Neuro-linguistic Programming Methods

Neuro linguistic Programming Methods There are several methods used for performing Neuro linguistic Programming on an individual for obtaining insights into the psyche of the person in order to correct to modify certain patterns of behavior These techniques are also used for Neuro linguistic trainin
 

The Difficult Past of Neuro-linguistic programming

The Difficult Past of Neuro linguistic programming Neuro linguistic programming has had a rocky past with a number of lawsuits rivalry unsystematic development and intermittent progress During the 1980s the two founders separated after the lawsuit filed by Bandler Bandler went on to file several law
 

About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape