순수 java application 개발 시 logback 사용 설정
5라인에서 config 하도록 설정
1 2 3 4 5 6 7 8 9 10 11 12 13 | public class FileRead { private static final Logger logger = LoggerFactory.getLogger(FileRead.class); static { BasicConfigurator.configure(); } public static void main(String[] args){ logger.info("test"); logger.info("test end"); } } | cs |
resources 아래에 logback.xml 로 logback 설정파일을 만들어야 함
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | <?xml version="1.0" encoding="UTF-8"?> <Configuration> <Appenders> <Console name="console" target="SYSTEM_OUT" class="org.apache.log4j.ConsoleAppender"> <PatternLayout pattern="[%d{yyyy-MM-dd HH:mm:ss}] %-5p: %c - %m%n" /> </Console> </Appenders> <Loggers> <Logger name="java.sql.Connection" level="DEBUG" additivity="false"> <AppenderRef ref="console" /> </Logger> <Logger name="java.sql.Statement" level="DEBUG" additivity="false"> <AppenderRef ref="console" /> </Logger> <Logger name="java.sql.PreparedStatement" level="DEBUG" additivity="false"> <AppenderRef ref="console" /> </Logger> <Logger name="java.sql.ResultSet" level="TRACE" additivity="false"> <AppenderRef ref="console" /> </Logger> <Logger name="java.sql.CallableStatement" level="DEBUG" additivity="false"> <AppenderRef ref="console" /> </Logger> <Root level="DEBUG"> <AppenderRef ref="console" /> </Root> </Loggers> </Configuration> | cs |
참고링크 : https://github.com/sonegy/how-to-use-logback
https://stackoverflow.com/questions/12532339/no-appenders-could-be-found-for-loggerlog4j
'Java' 카테고리의 다른 글
resource file 읽기 (0) | 2018.12.18 |
---|---|
eclipse task tag 사용(TODO) (0) | 2018.12.18 |
[Java] maven java application(standalone) mybatis 연결하기 (0) | 2018.12.18 |
java project 실행가능한 jar file 만들기 (0) | 2018.08.24 |
[Eclipse]java compiler level does not match the version of the installed java project facet (0) | 2018.01.13 |