Results 1 to 4 of 4
  1. #1
    nirasiva is offline Member
    Join Date
    May 2011
    Location
    chennai
    Posts
    29
    Rep Power
    0

    Default How to create a instance for logger?

    package com.my;
    import org.apache.log4j.spi.LoggerFactory;
    import java.io.*;
    import java.util.logging.*;

    public class Log {


    public static void main(String[] args) {
    try{
    FileHandler hand = new FileHandler("vk.log");
    Logger log = Logger.getLogger("log_file");
    log.getLogger("");
    log.addHandler(hand);
    log.warning("Doing carefully!");
    log.info("Doing something ...");
    log.severe("Doing strictily ");
    System.out.println(log.getName());
    }
    catch(IOException e){}
    }
    }

    Hello sir am new in log 4j..i dunno how to create a instance this logger can you guide me
    Last edited by nirasiva; 06-03-2011 at 02:16 PM. Reason: to insert my code

  2. #2
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    9

    Cool

    Quote Originally Posted by nirasiva View Post
    Hello sir am new in log 4j..i dunno how to create a instance this logger can you guide me
    Have a look at this article : How to use log4j logging API

    Hope that helps,

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

  3. #3
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    11

    Default

    What happens when you run the code? Does it compile? Throw exceptions? Not behave properly? Where/how do you configure the logger?
    In times like this, its always good to refer to the manual: Apache log4j 1.2 - Short introduction to log4j (in particular, see the example under Confuguration)

  4. #4
    nirasiva is offline Member
    Join Date
    May 2011
    Location
    chennai
    Posts
    29
    Rep Power
    0

Similar Threads

  1. [HELP] cannot create instance of jdialog???
    By clydedoris in forum New To Java
    Replies: 0
    Last Post: 07-21-2010, 09:02 AM
  2. Find instance that owns instance?
    By Addez in forum New To Java
    Replies: 2
    Last Post: 04-04-2010, 03:36 PM
  3. create new instance of variable class
    By Fedor in forum New To Java
    Replies: 5
    Last Post: 04-12-2009, 08:13 PM
  4. create Instance of class in Javascript
    By TDMaster in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 03-09-2009, 04:26 PM
  5. Create different instance of a tablemodel
    By Bill in forum AWT / Swing
    Replies: 6
    Last Post: 03-27-2008, 03:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •