JAKARTAPROJECT
JAKARTA TIPJSP TIPJSP Áú¹®&´äº¯DATABASE TIPJAVASCRIPT TIPWEBHACKING TIP±âŸ TIP
ÀÚÄ«¸£Å¸ ÇÁ·ÎÁ§Æ®
ÀÚÄ«¸£Å¸ ÇÁ·ÎÁ§Æ®
ÀÚÄ«¸£Å¸ ÇÁ·ÎÁ§Æ® ÆÁ °Ô½ÃÆÇ ÀÔ´Ï´Ù
log4j °í±Þ½º·´°Ô »ç¿ëÇϱâ
kaiser
À̹ÌÁö ½½¶óÀÌ´õ º¸±â

·Î±×¸¦ Ä¿½ºÅÍ ¸¶ÀÌ¡À» ÇÏ·Á°í ÇÒ¶§ »ç¿ëÇÕ´Ï´Ù.

 

ÇÊ¿äÇÑ ÆÄÀÏÀº 3°³ÀÌ°í

 

MyLogger.java

 

MyLoggerFactory.java

 

XLevel.java

 

ÀÌ°í ¼öÁ¤Àº MyLogger.java ¿¡¼­¸¸ ¼öÁ¤ÇÏ½Ã¸é µÇ°í

 

ÀÌ°ÍÀº log4j ´Ù¿î¹ÞÀ¸¸é ±×¼Ó¿¡ ¿¹Á¦°¡ µé¾î ÀÖ½À´Ï´Ù.

 

³ª¸ÓÁö´Â ¼öÁ¤ÇÒ ÀÏÀÌ ¾ø±â ¶§¹®¿¡ MyLogger.java ¸¸ ¼³¸íÇÏ°Ú½À´Ï´Ù.

 

 

import org.apache.log4j.*;
import org.apache.log4j.PropertyConfigurator;
import javax.servlet.http.HttpSession;
import org.apache.commons.lang.StringUtils;

/**
   A simple example showing logger subclassing.
   <p>See <b><a href="doc-files/MyLogger.java">source code</a></b>
   for more details.
   <p>See {@link MyLoggerTest} for a usage example.
 */
public class MyLogger extends Logger {
  // »ç¿ëÀÚ Á¤º¸
  User userInfo;

 

  // It's usually a good idea to add a dot suffix to the fully
  // qualified class name. This makes caller localization to work
  // properly even from classes that have almost the same fully
  // qualified class name as MyLogger, e.g. MyLoggerTest.
  static String FQCN = MyLogger.class.getName() + ".";

  // It's enough to instantiate a factory once and for all.
  private static MyLoggerFactory myFactory = new MyLoggerFactory();

  /**
     Just calls the parent constuctor.
   */
  public MyLogger(String name) {
    super(name);
    PropertyConfigurator.configure("/data1/bea/wlserver6.1/log4j/log4j.properties");

ÀÌ·¸°Ô Çϸé log4j.properties ÆÄÀÏÀÇ À§Ä¡µµ º¯°æÇÒ ¼ö ÀÖ´Ù.
  }
 
  /**
   * ²À ÇÊ¿äÇÑ°÷À» log·Î ¶³¾îÆ®¸°´Ù.
   * @param message
   */

  public void debug(Object message) {

    super.log(FQCN, Level.DEBUG, message, null);
  }

  public void debug(User userInfo, Object message) {
    super.log(FQCN, Level.DEBUG, userInfo.getUser_id() + ":" + message, null);
  }

ÀÌ·¸°Ô ¸Þ¼Òµå¸¦ ¸¸µé¾î¼­ »ç¿ëÇÏ½Ã¸é ¼Ò½º¿¡ ÀÏÀÏÀÌ ¾ÈÇصµ µÇ´Ï±î  ÆíÇϳ׿ä

 

  public void debug(HttpSession session, Object message) {
    String user = StringUtils.stripToEmpty( ( (User) session.getAttribute("UserInfo")).getUser_id());
    super.log(FQCN, Level.DEBUG, user + ":" + message, null);
  }

  /**
     This method overrides {@link Logger#getLogger} by supplying
     its own factory type as a parameter.
   */
  public static Logger getLogger(String name) {
    return Logger.getLogger(name, myFactory);
  }

  /**
   * ÀÏ¹Ý °ªÀ» °ËÁõÇÒ¶§ ¾´´Ù.
   * @param message
   */
  public void trace(Object message) {
    super.log(FQCN, XLevel.TRACE, message, null);
  }
}

 

 

[»ç¿ë¹æ¹ý]

 

<%@ page import="org.apache.log4j.*"%>

<% MyLogger log = (MyLogger) MyLogger.getLogger("loginProcess.jsp"); %>

<%

       log.info("¿øÇÏ´Â °ª : "+ ¿øÇÏ´Â °´Ã¼);

       log.debug("¿øÇÏ´Â °ª : "+ ¿øÇÏ´Â °´Ã¼);

// info, debug´Â ¼³Á¤°ª¿¡¼­ Á¤ÇÒ¼ö Àֱ⶧¹®¿¡ Á¤Ã¥À» Á¤Çؼ­ ÇÏ½Ã¸é µÉ°Í °°½À´Ï´Ù.

%>

 

java ÆÄÀÏ¿¡µµ ¹°·Ð »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù. À̶§´Â ¼¼¼ÇÀÌ ¾øÀ¸´Ï±î...´Ù¸¥ ¸Þ¼Òµå¸¦

È£ÃâÇÏ°ÚÁ®..ÂÁ..

2005-04-18 18:21:51
211.50.216.***

¼­Çö»ç¶û~ ¾È³ç ¾È³ç ³ªÀÇ ¾Æ±âº°~~

÷ºÎÆÄÀÏ (ÃÑ 3°³)
  1. XLevel.java 1.67 KB (252 ´Ù¿î·Îµå)
  2. MyLoggerFactory.java 754 Bytes (292 ´Ù¿î·Îµå)
  3. MyLogger.java 2.3 KB (281 ´Ù¿î·Îµå)
0Á¡ (0¸í)
µ¡±Û 2°³ | ÅÂ±× 1°³ | °ü·Ã±Ûº¸±â
ű×ÀÔ·Â
½±Ç¥(,)±¸ºÐÀ¸·Î Çѹø¿¡ ¿©·¯ ű׸¦ ÀÔ·ÂÇÒ¼ö ÀÖ½À´Ï´Ù
log4j (4)
kaiser
(0) (0)
¼º´ë¾¾ °¡ÀÔ±â³äÀ¸·Î Çϳª ¿Ã·È´Âµ¥...ÂÁ..
211.50.216.*** 2005-04-18 18:22:41
GoodBug
(0) (0)
¸¹Àº È°µ¿ ±â´ë ¸¸»§ ^^
211.189.124.*** 2005-04-18 18:49:34
À̸§ ºñ¹Ð¹øÈ£
ÀÚÄ«¸£Å¸ ÇÁ·ÎÁ§Æ®
ÀÚÄ«¸£Å¸ ÇÁ·ÎÁ§Æ® ÆÁ °Ô½ÃÆÇ ÀÔ´Ï´Ù
! ¹øÈ£ Á¦¸ñ ±Û¾´ÀÌ ÀÏÀÚ Á¶È¸
Hierarchy of the Apache Software Foundation GoodBug 2005-10-14 10,814
Jakarta Project °­Á °Ô½ÃÆÇÀÔ´Ï´Ù 8 GoodBug 2005-04-03 11,701
44 Log4J log4j¿¡¼­ e.printStackTrace() ¸Þ½ÃÁö¸¦ log¿¡ ³²±â´Â ¹æ¹ý 1 kaiser 2008-10-22 17,613
43 DBUtils DBUtils¿¡¼­ Clob »ç¿ëÇϱâ 3 1 GoodBug 2007-08-28 10,633
42 Spring Spring ¼³Á¤ ÆÄÀÏ ·Îµù 1 GoodBug 2007-07-16 11,317
41 POI POIÀÇ HSLF¸¦ ÀÌ¿ëÇÏ¿© PowerPoint ¹®¼­¸¦ ÀоÀÚ 2 GoodBug 2007-05-28 14,910
40 POI POIÀÇ HWPF¸¦ ÀÌ¿ëÇÏ¿© MS WORD¹®¼­¸¦ ÀоÀÚ 2 GoodBug 2007-05-28 16,839
39 Validator Validator ¼Ó¼ºµé 1 GoodBug 2007-05-11 10,404
38 dd Commons-Fileupload 1.2 1 2 GoodBug 2007-04-23 15,345
37 Apache Apache2 + Tomcat5.5 + mod_jk 4 ¹ÙÀÌ·¯½ºô¸国 2007-01-29 11,066
36 DBUtils DBUtils¿¡¼­ number ŸÀÔÀÇ Ä÷³ÀÌ intÇüÀ¸·Î ¾È³Ñ¾î¿Ã¶§.. 3 1 GoodBug 2006-06-28 10,755
35 ÈìÈì À§ÇèÇÑ static Logger Çʵå... 2 1 ¼­¿¬¾Æºü 2006-03-16 10,113
34 Installing Tomcat with commons-daemon (jsvc) GoodBug 2006-01-08 9,067
33 commons Commons DbUtils ¸î°¡Áö ¿¹Á¦ 3 2 GoodBug 2005-11-17 15,221
32 commons Jakarta Commons Net ¿¡¼­ FTP »ç¿ë½Ã ¸ñ·ÏÀÌ ¾Èº¸ÀÏ °æ¿ì 2 GoodBug 2005-11-15 21,776
31 listFiles() ¿¡¼­ null À» ¹Ýȯ ÃßÀû.. ½Å¸¸µÎ 2008-11-11 11,866
30 commons ¸ñ·ÏÀÌ ¾Èº¸ÀÏ °æ¿ì ÇØ°á±â Iź 1 2 GoodBug 2005-12-23 15,932
29 POI POI·Î ¿¢¼¿ÆÄÀÏ ÀÐÀ»¶§, Invalid header signature ¿¡·¯ 1 GoodBug 2005-11-12 16,540
28 log4j log4j, JSP¿¡¼­ ¿øÇÏ´Â Appender °ñ¶ó¾²±â 1 GoodBug 2005-11-07 13,894
27 commons Commons-Email~ 7 2 GoodBug 2005-10-13 17,860
copyright 2005-2024 by Unicorn