Package system.util

Source Code of system.util.LogUtil

/*
* LogUtil.java
*
* Created on 2009. oktober 20., 15:40
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

package system.util;

import javax.swing.JOptionPane;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

/**
*
* @author laci
*/
public class LogUtil {
 
// <editor-fold defaultstate="collapsed" desc="Parameterek">
 
  public static final int INFO = 0;
 
  public static final int DEBUG = 1;
 
  public static final int WARN = 2;
 
  public static final int ERROR = 3;
 
  public static final int FATAL = 4;
 
// </editor-fold>
 
// <editor-fold defaultstate="collapsed" desc="log">
        public static void log(String szoveg, Class osztaly, int szint) {
            log(szoveg,osztaly,null,szint);
        }
 
  public static void log(String szoveg, Class osztaly, Exception error, int szint) {
    Logger temp = Logger.getLogger(osztaly);
    if (error != null) {
                szoveg += "\n"+error.toString();
        if (error.getMessage() != null)
          szoveg += "\n"+error.getMessage();
    }
    PropertyConfigurator.configure(org.apache.log4j.helpers.Loader.getResource("swing/properties/log4j.properties").getFile());
   
    switch (szint) {
      case INFO: {
        temp.info(szoveg);
        break;
      }
      case DEBUG: {
        temp.debug(szoveg);
        break;
      }
      case WARN: {
        JOptionPane.showMessageDialog(null, szoveg, "Hiba t�rt�nt", JOptionPane.WARNING_MESSAGE);
        temp.warn(szoveg);
        break;
      }
      case ERROR: {
        JOptionPane.showMessageDialog(null, szoveg, "Hiba t�rt�nt", JOptionPane.ERROR_MESSAGE);
        temp.error(szoveg);
        break;
      }
      case FATAL: {
        JOptionPane.showMessageDialog(null, szoveg, "Hiba t�rt�nt", JOptionPane.ERROR_MESSAGE);
        temp.fatal(szoveg);
        break;
      }
    }
  }
 
// </editor-fold>
 
}
TOP

Related Classes of system.util.LogUtil

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.