log4j.xml 등록하기
package com.howtodoinjava;import org.apache.log4j.Logger;import org.apache.log4j.xml.DOMConfigurator;public class Log4jXmlConfigurationExample{ static Logger logger = Logger.getLogger(Log4jXmlConfigurationExample.class); public static void main(String[] args) { //DOMConfigurator is used to configure logger from xml configuration file DOMConfigurator.configure("config/log4j-config.xml"); //Log in console in and log file logger.debug("Log4j appender configuration is successful !!"); }} |
log4j.properties 등록하기
Properties props = new Properties();
props.load(new FileInputStream("config/log4j.properties"));
PropertyConfigurator.configure(props);If the properties file is in the jar, then you could do something like this:
Properties props = new Properties();
props.load(getClass().getResourceAsStream("/log4j.properties"));
PropertyConfigurator.configure(props);'소소한 개발팁' 카테고리의 다른 글
| 러닝커브~ (0) | 2016.07.15 |
|---|---|
| 빅엔디안(Big-Endian), 리틀엔디안(Little-Endian) (0) | 2016.06.02 |
| 용어 하나씩 추가해보자!(약자) (0) | 2016.04.05 |
| soap && rest (0) | 2015.09.17 |
| rtp패킷구조 (0) | 2015.04.24 |