- 관련 jar 를 다운받아서 프로젝트에 추가합니다.

- 클래스패스에 log4j.xml 파일을 추가합니다. 

- log4j.xml 파일에 아래 내용을 써 넣습니다.


1.  Console 로 출력 


<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration debug="true"

xmlns:log4j='http://jakarta.apache.org/log4j/'>

 

<appender name="console" class="org.apache.log4j.ConsoleAppender">

   <layout class="org.apache.log4j.PatternLayout">

<param name="ConversionPattern" 

 value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />

   </layout>

</appender>

 

<root>

<level value="DEBUG" />

<appender-ref ref="console" />

</root>

 

</log4j:configuration>


<level value="DEBUG"/>: DEBUG 레벨부터 출력하라. 

<appender-ref ref="console"/>: console 에 출력할거야.


2. 파일로 출력 


<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration debug="true"

xmlns:log4j='http://jakarta.apache.org/log4j/'>

 

<appender name="file" class="org.apache.log4j.RollingFileAppender">

  <param name="append" value="false" />

  <param name="maxFileSize" value="10KB" />

  <param name="maxBackupIndex" value="5" />

  <!-- For Tomcat -->

  <param name="file" value="${catalina.home}/logs/myStruts1App.log" />

  <layout class="org.apache.log4j.PatternLayout">

<param name="ConversionPattern" 

value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />

  </layout>

</appender>

 

<root>

<level value="ERROR" />

<appender-ref ref="file" />

</root>

 

</log4j:configuration>


<param name="append" value="false" />: 어플리케이션 실행시마다 덮어쓸것이냐? 뒤에 붙힐것이냐? 디폴트 : true


3. 콘솔과 파일에 출력 


<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration debug="true"

  xmlns:log4j='http://jakarta.apache.org/log4j/'>

 

<appender name="console" class="org.apache.log4j.ConsoleAppender">

   <layout class="org.apache.log4j.PatternLayout">

<param name="ConversionPattern" 

value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />

   </layout>

</appender>

 

<appender name="file" class="org.apache.log4j.RollingFileAppender">

   <param name="append" value="false" />

   <param name="maxFileSize" value="10MB" />

   <param name="maxBackupIndex" value="10" />

   <param name="file" value="${catalina.home}/logs/myStruts1App.log" />

   <layout class="org.apache.log4j.PatternLayout">

<param name="ConversionPattern" 

value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />

   </layout>

</appender>

 

<root>

<level value="DEBUG" />

<appender-ref ref="console" />

<appender-ref ref="file" />

</root>

 

</log4j:configuration>


<appender-ref ref="file" />: file 에 출력할거야.

${catalina.home}/logs/myStruts1App.log: 이 위치에 출력할거야.  


3. 패키지/클래스별 출력 

    <logger name="org.springframework" additivity="false">

        <level value="WARN" />

        <appender-ref ref="console" />

        <appender-ref ref="file" />

    </logger>


"org.springframework"         은 WARN 이상부터만 출력하라~ 

 additivity="false"               로그 이벤트가 부모에서 전달되지 않는다. 


4. 날짜별 파일 출력



5. 용량별 파일 출력



 



레퍼런스: 

http://www.mkyong.com/logging/log4j-xml-example/

http://seosh81.info/?p=404

http://logging.apache.org/log4j/1.2/manual.html



1. 프로젝트를 개인 컴퓨터에서 만든다. 마구마구 개발을한다. ver 0.1 이 나왔다.

2. 자 공유할 시간이 됬다.

3. git  서버에 그 프로젝트를 위한 디렉토리를 구성해준다. 다음 명령어 (  git init --bare --share  )



4. 로컬의 이클립스에서 새로만든 서버에 프로젝트를 올려준다.


4-1. Project 에서 Team > ShareProject > LocalGit 생성


4-2. Team > Commit > Commit & Push

4-3. 원격 설정 입력 및 Finish




'데브옵스' 카테고리의 다른 글

log4j 예제 & 설명  (0) 2015.08.03
배포와 버전 관리  (0) 2015.05.24
java endorsed 매커니즘  (0) 2015.05.24
예외와 로그 코딩 실용 가이드  (0) 2015.05.24

http://www.slideshare.net/dhrim/ss-2804901


      예전에 스터디를 같이했던 멤버분의 발표자료입니다.  (링크로 가서 보세요)        




endorsed의 의미 : http://aploit.egloos.com/4806304


http://docs.oracle.com/javase/7/docs/technotes/guides/standards/

Java Endorsed Standards Override Mechanism

The following topics are covered:

Introduction

From time to time it is necessary to update the Java platform in order to incorporate newer versions of standards that are created outside of the Java Community Process (Endorsed Standards), or in order to update the version of a technology included in the platform to correspond to a later standalone version of that technology (Standalone Technologies).

The Endorsed Standards Override Mechanism provides a means whereby later versions of classes and interfaces that implement Endorsed Standards or Standalone Technologies may be incorporated into the Java Platform.

Deploying Updated Packages

Packages to be updated through this mechanism should be placed in JAR files. The system property java.endorsed.dirs specifies one or more directories that the Java runtime environment will search for such JAR files. If more than one directory path is specified by java.endorsed.dirs, they must be separated byFile.pathSeparatorChar. If no value is set for java.endorsed.dirs, then Sun Microsystem's implementation of the Java platform looks for JAR files in a default standard location:

<java-home>\lib\endorsed          [Microsoft Windows]
<java-home>/lib/endorsed          [Solaris or Linux]

Here <java-home> refers to the directory where the runtime software is installed (which is the top-level directory of the Java SE Runtime Environment or the jredirectory in the JDK).

The Java SE runtime environment will use classes in such JAR files to override the corresponding classes provided in the Java platform as it was shipped.

Endorsed Standards APIs

The Endorsed Standards for Java SE constitute all classes and interfaces that are defined in the packages listed in this section. Classes and interfaces defined in sub-packages of listed packages are not Endorsed Standards unless those sub-packages are themselves listed. The Endorsed Standards Override Mechanism may be used to override the Java SE platform packages in this list, and these packages may be overridden only by versions of the Endorsed Standard that are newer than that provided by the Java platform as released by Sun. With the exception of packages listed here and the technologies listed in the Standalone Technologiessection below, no other packages from the Java SE platform API specification may be overridden.

javax.rmi.CORBA
org.omg.CORBA
org.omg.CORBA.DynAnyPackage
org.omg.CORBA.ORBPackage
org.omg.CORBA.portable
org.omg.CORBA.TypeCodePackage
org.omg.CORBA_2_3
org.omg.CORBA_2_3.portable
org.omg.CosNaming
org.omg.CosNaming.NamingContextExtPackage
org.omg.CosNaming.NamingContextPackage
org.omg.Dynamic
org.omg.DynamicAny
org.omg.DynamicAny.DynAnyFactoryPackage
org.omg.DynamicAny.DynAnyPackage
org.omg.IOP
org.omg.IOP.CodecFactoryPackage
org.omg.IOP.CodecPackage
org.omg.Messaging
org.omg.PortableInterceptor
org.omg.PortableInterceptor.ORBInitInfoPackage
org.omg.PortableServer
org.omg.PortableServer.CurrentPackage
org.omg.PortableServer.POAManagerPackage
org.omg.PortableServer.POAPackage
org.omg.PortableServer.portable
org.omg.PortableServer.ServantLocatorPackage
org.omg.SendingContext
org.omg.stub.java.rmi
org.w3c.dom
org.xml.sax
org.xml.sax.ext
org.xml.sax.helpers

In addition to the packages listed above, which are part of the Java SE specification, users of Sun's Java SE Reference Implementation are allowed to use the Endorsed Standards Override Mechanism to override implementation-specific classes associated with these packages, such as the org.w3c.dom sub-packages delivered in Sun's Reference Implementation.

Standalone Technologies

The Standalone Technologies for Java SE constitute all classes and interfaces that are defined and implemented in the technologies listed in this section. The Endorsed Standards Override Mechanism may be used to override the Java technologies in this list, and these technologies may be overridden only by providing a complete and newer implementation of the Standalone Technology than was provided in the original implementation of the Java Platform. With the exception of the technologies in this list and the packages listed in the Endorsed Standards APIs section above, no other packages from the Java SE platform API specification may be overridden.

Standalone TechnologySupported Implementation Version
Java API for XML Processing (JAXP)1.4.5
Java Architecture for XML Binding (JAXB)2.2.4-1
Java Compiler API1.0
Pluggable Annotation Processing API1.7
Common Annotations for the Java Platform1.1
Scripting for the Java Platform1.0
SOAP with Attachments API for Java (SAAJ) (package javax.xml.soap)1.3.9


     예전에 스터디를 같이했던 멤버분의 발표자료입니다. (링크로 가서 보세요)          

http://www.slideshare.net/dhrim/exception-log-practicalcodingguide




'데브옵스' 카테고리의 다른 글

log4j 예제 & 설명  (0) 2015.08.03
회사 GIT 설정 - 기본 GIT 서버 에 로컬 프로젝트 EXPORT  (0) 2015.07.13
배포와 버전 관리  (0) 2015.05.24
java endorsed 매커니즘  (0) 2015.05.24

+ Recent posts