Site Search :
Standard Enterprise XML Methodology Pattern Setting Tunning Other
Article Contributors
GuestBook
Javapattern Maven
XSourceGen Dev
JetSpeed Test
JLook Image
jLook Family Site


Log4j¸¦ À§ÇÑ ¿©·¯°¡Áö ȯ°æ¼³Á¤(xml property)
 
À̹ø±ÛÀº XMLÀ» ÀÌ¿ëÇÑ property¼³Á¤À» ÀÌ¿ëÇÏ¿© jakarta-log4jÀÇ È¯°æ¼³Á¤ ¹× Å×½ºÆ® ±¸µ¿ÆÄÀÏ¿¡ ´ëÇÑ »ç¿ë¹æ¹ýÀ» ¼³¸íÇÑ´Ù. ( 2003/02/28 ) 692
Written by ienvyou - ÃÖÁö¿õ
2 of 2
 
<font face='±¼¸²'>1. console appender
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration>

<appender name="A1" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
	<param name="ConversionPattern" value="%d %-5p [%t] %-17c{2} (%13F:%L) %3x - %m%n"/>
</layout>
</appender>


<root>
<priority value ="debug" />
<appender-ref ref="A1"/>
</root>

</log4j:configuration>

2. <?xml version="1.0" encoding="euc-kr" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<!-- 
ÆÄÀÏ¿¡ ·Î±×¸¦ ±â·ÏÇÏ´Â »ùÇÃÀÔ´Ï´Ù. 
±âº»ÀûÀ¸·Î ·Î±×ÆÄÀÏÀÇ À̸§À» ±â·ÏÇÒ ¼ö ÀÖÀ¸¸ç
ÇØ´ç¼³Á¤Àº root logger¿¡ ¼³Á¤µÇ¾î ÀÖ´Â ³»¿ëÀ» ÂüÁ¶ÇÏ¿© ¼³Á¤ÀÌ °¡´ÉÇÕ´Ï´Ù.
¾Æ·¡ÀÇ ¼³Á¤ÆÄÀÏÀº ¸ÅÀϷα׸¦ ³²±æ¼ö ÀÖ´Â ÇüÅ¿©¼­ ÇüÅ°¡ ´Ù¾çÇÏ°Ô ³ªÅ¸³¯¼ö ÀÖ½À´Ï´Ù.
³¯Â¥º¯°æÀÌ µÇ¸é ÀÚµ¿À¸·Î ·Î±×°¡ ¹Ù²ò´Ï´Ù.
-->
<log4j:configuration>

<appender name="A1" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="ienvyou.log"/>
<param name="Append" value="false"/>
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<layout class="org.apache.log4j.PatternLayout">
	<param name="ConversionPattern" value="%d %-5p [%t] %-17c{2} (%13F:%L) %3x - %m%n"/>
</layout>
</appender>


<root>
<priority value ="debug" />
<appender-ref ref="A1"/>
</root>

</log4j:configuration>

3.  File¿¡ ·Î±×¸¦ °è¼ÓÀûÀ¸·Î ½×ÀÌ°Ô ÇÏ´Â ¹æ¹ý

<?xml version="1.0" encoding="euc-kr" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<!-- 
ÆÄÀÏ¿¡ ·Î±×¸¦ ±â·ÏÇÏ´Â »ùÇÃÀÔ´Ï´Ù. 
±âº»ÀûÀ¸·Î ·Î±×ÆÄÀÏÀÇ À̸§À» ±â·ÏÇÒ ¼ö ÀÖÀ¸¸ç
ÇØ´ç¼³Á¤Àº root logger¿¡ ¼³Á¤µÇ¾î ÀÖ´Â ³»¿ëÀ» ÂüÁ¶ÇÏ¿© ¼³Á¤ÀÌ °¡´ÉÇÕ´Ï´Ù.
-->
<log4j:configuration>

<appender name="A1" class="org.apache.log4j.FileAppender">
<param name="File" value="ienvyou.log"/>
<param name="Append" value="false"/>
<layout class="org.apache.log4j.PatternLayout">
	<param name="ConversionPattern" value="%d %-5p [%t] %-17c{2} (%13F:%L) %3x - %m%n"/>
</layout>
</appender>


<root>
<priority value ="debug" />
<appender-ref ref="A1"/>
</root>

</log4j:configuration>


4. Ãâ·ÂÀ» XMLÆ÷¸ËÀÇ ÆÄÀÏ·Î ÇÏ´Â ¹æ¹ý
<?xml version="1.0" encoding="euc-kr" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<!-- 
ÆÄÀÏ¿¡ ·Î±×¸¦ ±â·ÏÇÏ´Â »ùÇÃÀÔ´Ï´Ù. 
±âº»ÀûÀ¸·Î ·Î±×ÆÄÀÏÀÇ À̸§À» ±â·ÏÇÒ ¼ö ÀÖÀ¸¸ç
ÇØ´ç¼³Á¤Àº root logger¿¡ ¼³Á¤µÇ¾î ÀÖ´Â ³»¿ëÀ» ÂüÁ¶ÇÏ¿© ¼³Á¤ÀÌ °¡´ÉÇÕ´Ï´Ù.
Ãâ·ÂÀº XMLÇüÅÂÀÇ ÆÄÀÏ·Î ÀúÀåµË´Ï´Ù.
-->
<log4j:configuration>

<appender name="A1" class="org.apache.log4j.FileAppender">
<param name="File" value="ienvyou.log"/>
<param name="Append" value="false"/>
<layout class="org.apache.log4j.xml.XMLLayout"/>
</appender>


<root>
<priority value ="debug" />
<appender-ref ref="A1"/>
</root>

</log4j:configuration>

5. ÆÄÀÏÀÌ ÀÏÁ¤¿ë·®(¿¹Á¦:100KB) ÀÌ µÇ¸é xxx.log.1, xxx.log.2ÀÇ ÇüÅ·Πº¯°æ½ÃÅ°´Â ¹æ¹ý
<?xml version="1.0" encoding="euc-kr" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<!-- 
ÆÄÀÏ¿¡ ·Î±×¸¦ ±â·ÏÇÏ´Â »ùÇÃÀÔ´Ï´Ù. 
±âº»ÀûÀ¸·Î ·Î±×ÆÄÀÏÀÇ À̸§À» ±â·ÏÇÒ ¼ö ÀÖÀ¸¸ç
ÇØ´ç¼³Á¤Àº root logger¿¡ ¼³Á¤µÇ¾î ÀÖ´Â ³»¿ëÀ» ÂüÁ¶ÇÏ¿© ¼³Á¤ÀÌ °¡´ÉÇÕ´Ï´Ù.
¾Æ·¡ÀÇ ¼³Á¤ÆÄÀÏÀº ÀÏÁ¤ÆÄÀÏ»çÀÌÁî°¡ µÇ¸é ÆÄÀϺ¯°æ
-->
<log4j:configuration>

<appender name="A1" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="ienvyou.log"/>
<param name="Append" value="false"/>
<param name="MaxFileSize" value="100KB"/>
<layout class="org.apache.log4j.PatternLayout">
	<param name="ConversionPattern" value="%d %-5p [%t] %-17c{2} (%13F:%L) %3x - %m%n"/>
</layout>
</appender>


<root>
<priority value ="debug" />
<appender-ref ref="A1"/>
</root>

</log4j:configuration>

À§¿Í °°Àº ÇüÅÂÀÇ xmlÆÄÀÏÀ» ÀÌ¿ëÇÏ¸é ´Ù¾çÇÑ ·Î±×¸¦ ³²±æ¼ö ÀÖÀ¸¸ç
À¯¿ëÇÏ°Ô »ç¿ëÇÒ ¼ö ÀÖÀ¸¸®¶ó º»´Ù.
 
1 2
References
 
http://jakarta.apache.org
Copyright ¨Ï 2003 www.javapattern.info & www.jlook.com, an jLOOK co.,LTD