hi kwok

how to initialize the class

what am i doing is 

i m having loggers.java as

package com.pronto.util;

import java.io.*;
import java.util.*;
import org.apache.log4j.*;

/**
 * Title:
 * Description:  Uses new Log4j class to log all the
message to a file
 * Copyright:    Copyright (c) 2003
 * Company:
 * @author Sathish Babu
 * @version 1.0
 */

public class Loggers {

  public static int DEBUG_LOG_LEVEL = 10000;
  public static int INFO_LOG_LEVEL = 20000;
  public static int ERROR_LOG_LEVEL = 40000;

  private static PrintWriter _printWriter = null;
  private static String _logFile = null;
  private static int _logLevel;
  private static Logger logger =
Logger.getLogger("com.pronto.web");

  public static TreeMap levels = new TreeMap();
  static {
    levels.put(String.valueOf(DEBUG_LOG_LEVEL),
"DEBUG");
    levels.put(String.valueOf(INFO_LOG_LEVEL),
"INFO");
    levels.put(String.valueOf(ERROR_LOG_LEVEL),
"ERROR");
    _logLevel = logger.getLevel().toInt();
        ConsoleAppender app
=(ConsoleAppender)logger.getAppender("Log");
   // RollingFileAppender app
=(RollingFileAppender)logger.getAppender("Log");
   // _logFile = app.getFile();
  }

  public synchronized static void logMessage(Object
message, int logLevel) {
          System.out.println("got into log message");
    /*if(logLevel == ERROR_LOG_LEVEL)
          {
      logger.error(message);
          }
    else if(logLevel == INFO_LOG_LEVEL)
          {
      logger.info(message);
          }
    else
          {*/
                System.out.println("got into debug message");
      logger.debug(message);
          //}
  }

  public static void setLoggingLevel(int level) {
    if( logger.getLevel().toInt() != level ) {
      if(level == DEBUG_LOG_LEVEL)
        logger.setLevel(Level.DEBUG);
      if(level == INFO_LOG_LEVEL)
        logger.setLevel(Level.INFO);
      if(level == ERROR_LOG_LEVEL)
        logger.setLevel(Level.ERROR);
      logMessage("Setting logging level to " +
levels.get(String.valueOf(level)), level);
    }
  }

  public static void clearLogFile()  {
    try {
      if(_printWriter != null)
        _printWriter.close();
      _printWriter = new PrintWriter(new
FileWriter(_logFile), true);
      logMessage("Cleared out logfile",
logger.getLevel().toInt());
    }
    catch(Exception e) {
      logMessage("Error while Clearing logfile
"+e.getMessage(), ERROR_LOG_LEVEL);
    }
  }

  public static void writeFileToWriter(Writer out) {
    try {
      BufferedReader br = new BufferedReader(new
FileReader(_logFile));
      char[] buff = new char[2048];
      int bytesRead;

      while(-1 != (bytesRead = br.read(buff, 0,
buff.length))) {
        out.write(buff, 0, bytesRead);
      }
      br.close();
    }
    catch(Exception e) {
      Loggers.logMessage("Error while writing the file
to writer " +e.getMessage(),ERROR_LOG_LEVEL);
    }
  }

  public static int getLoggingLevel() {
    return _logLevel;
  }

  private Loggers() {
  }
  public static void main(String[] args) 
        {
                System.out.println("Hello World!");
                Loggers.logMessage("stupid..idiot",
Loggers.ERROR_LOG_LEVEL);
        }
}
        

i m calling that in actionform class as 

Loggers.logMessage("stupid..idiot",
Loggers.DEBUG_LOG_LEVEL);

tell me solution

sathish

--- Kwok Peng Tuck <[EMAIL PROTECTED]> wrote:
> It says no class definition found rather than no
> class found, are you 
> initializing the class correctly ?
> Sathish Babu K R wrote:
> 
> >hi kalra
> >
> >yep i have that log4j in lib folder
> >
> >sathish
> >
> >__________________________________
> >Do you Yahoo!?
> >New Yahoo! Photos - easier uploading and sharing.
> >http://photos.yahoo.com/
> >
>
>---------------------------------------------------------------------
> >To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> >For additional commands, e-mail:
> [EMAIL PROTECTED]
> >
> >
> >
> >  
> >
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 


__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to