Java log4j Management (continuation of log4j encapsulation in Java) __java

Source: Internet
Author: User
Tags throwable wrapper log4j

/********************************************************************
* Final Update Date: $Date: 2005/11/16 05:48:47 $ [$Revision: 1.11 $]
* Last updated by: $Author: lhj_kk$
* Copyright (c) 2004-2006 NNN ATA CORPORATION, All rights reserved.
********************************************************************/
Package jp.co.**.**.core.logging;

Import jp.co.**.**.core.constants.baseconstant;

Import Org.apache.log4j.Category;
Import Org.apache.log4j.PropertyConfigurator;

/**
 *ログマネジャクラス<br>
 * machine は below り<br>
 * <ul>
 * <li> static method でインスタンスを Aimi installed する
 * <li>ログインスタンスの get
 * </ul>
 * <br>
 * @since 1.0.0
 * @version <br>1.0.0 new 2005/09/30
 * @author  lhj
 */
public class Categorymanage implements Baseconstant {
 /**
  *カテゴリーインスタンス
  */
 private static Category Category = null;
 /**
  static method でインスタンスを Aimi Install する
  * log4j.properties
  */
 static {
   try {
   system.out.println ("Log4jログマネージャ initial メッソド");
   propertyconfigurator.configureandwatch (Log4jfile);
   
  } catch (Exception e) {
   e.printstacktrace ();
&NBSP;&NBSP}
 }

/**
*ログインスタンスの obtained
* @param thisclassカテゴリーのキー
* @return categoryカテゴリー
*/
public static synchronized Category getinstance (String thisclass) {
20051103 UC. UP-1 Land-yu fixed STA
if (! Serverlog.equals (ThisClass)) {
ThisClass = Serverlog;
}
if (category = = null) {
Category = Category.getinstance (ThisClass);
}
20051103 UC. UP-1 Land-yu correction end
return category;
}
}

2.

Package jp.co.nec.inf.frw.log;

Import Java.net.URL;

Import jp.co.nec.inf.frw.com.FrwCst;

Import Org.apache.log4j.Logger;
Import Org.apache.log4j.PropertyConfigurator;
Import Org.apache.log4j.xml.DOMConfigurator;

public class Frwadapterlog implements Frwlog {

public static final String xml_file_extension = ". XML";

static{
Log4j of the initial stage
URL url = FrwAdapterLog.class.getClassLoader (). getresource (frwcst.log4jfile_location);

if (FrwCst.LOG4JFILE_LOCATION.toLowerCase (). EndsWith (xml_file_extension)) {
Domconfigurator.configure (URL);
}
else {
Propertyconfigurator.configure (URL);
}
if (URL!= null) {
Domconfigurator.configure (URL);
} else {
Domconfigurator.configure (System.getproperty ("Log4j.configuration", "Log4j.xml"));
//  }
}

/**
*ロギング Ontology
*/
Private Org.apache.log4j.Logger Logger;

/**
*コンストラクタ
*
* @param clsログを Output するクラス
*/
Protected Frwadapterlog (Class CLS) {
Logger = Logger.getlogger (CLS);
}

/**
* Specify されたクラスでロギングを initial します.
*
* @param clsログを Output するクラス
*/
public static Frwlog getinstance (Class cls) {
Frwadapterlog wrapper = new Frwadapterlog (CLS);
return wrapper;
}

/**
*ログクラスを placed Earpick straight する.
*
* @param clsログクラス
*/
public void Resetlogger (Class cls) {
Logger = Org.apache.log4j.Logger.getLogger (CLS);
}


public void Debug (String message, throwable cause) {
Logger.debug (Message,cause);
}

public void error (String message, throwable cause) {
Logger.error (Message,cause);
}

public void info (String message, throwable cause) {
Logger.info (Message,cause);
}

public void warn (String message, throwable cause) {
Logger.warn (Message,cause);
}

public void Debug (String message) {
Logger.debug (message);
}

public void info (String message) {
Logger.info (message);
}

public void warn (String message) {
Logger.warn (message);
}

public void error (String message) {
Logger.error (message);
}


}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.