๐ขMaven : ๋น๋ ํด - ํ๋ก์ ํธ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๊ด๋ฆฌํ๋ ํ๋ก๊ทธ๋จ
๐pom.xml : Maven ๋น๋ ํด์ ์ด์ฉํ์ฌ ํ๋ก์ ํธ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๋น๋ํ๊ธฐ ์ํ ์ ๋ณด๋ฅผ ์ ๊ณตํ๋ ํ๊ฒฝ์ค์ ํ์ผ
โ ๋ก์ปฌ ์ ์ฅ์์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ์ผ์ ํ๋ก์ ํธ์ ๋น๋๋๋๋ก ์ฒ๋ฆฌ
โ ๋ก์ปฌ ์ ์ฅ์์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ์ผ์ด ์๋ ๊ฒฝ์ฐ ๋ฉ์ด๋ธ ์ ์ฅ์์์ ๋ค์ด๋ก๋ ๋ฐ์ ๋ก์ปฌ ์ ์ฅ์์ ์ ์ฅ
๐๋ก์ปฌ ์ ์ฅ์(Local Repository) : ํ๋ก์ ํธ์ ๋น๋๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ์ผ์ ์ ์ฅํ๊ธฐ ์ํ ํด๋
โ ์ฌ์ฉ์ ํด๋์ .m2 ํด๋๋ฅผ ๋ก์ปฌ ์ ์ฅ์๋ก ์ฌ์ฉ
๐๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ์ผ์ ๋ฌธ์ ๊ฐ ์๋ ๊ฒฝ์ฐ ์ดํด๋ฆฝ์ค ์ข ๋ฃ ํ .m2 ํด๋์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ์ผ์ ์ญ์ ํ๊ณ ์ดํด๋ฆฝ์ค ์ฌ์คํ
๐๋ฉ์ด๋ธ ์ ์ฅ์(Maven Repository) : ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ์ผ์ด ์ ์ฅ๋ ์ธํฐ๋ท์์ ์ ์ฅ์
โ https://mvnrepository.com ์ฌ์ดํธ ์ฐธ์กฐ
๐properties : pom.xml ํ์ผ์์ ์์ฃผ ์ฌ์ฉํ๋ ๊ฐ์ ์ด๋ฆ(์๋ณ์)์ ์ด์ฉํ์ฌ ๋ฑ๋กํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ
โ ํ์ ์๋ฆฌ๋จผํธ๋ช ์ด๋ฆ์ ๊ฐ์ ๊ตฌ๋ถํ๊ธฐ ์ํ ์๋ณ์๋ก ์ฌ์ฉํ๋ฉฐ ์๋ฆฌ๋จผํธ ๋ด์ฉ์ด ์ ๊ณต๋๋ ๊ฐ์ ํํ
โ pom.xml ํ์ผ์์ ${์ด๋ฆ} ํ์์ผ๋ก ๊ฐ์ ์ ๊ณต๋ฐ์ ์ฌ์ฉ ๊ฐ๋ฅ
โ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๋ฒ์ ์ ํจ์จ์ ์ผ๋ก ๊ด๋ฆฌํ๊ธฐ ์ํด properties ์๋ฆฌ๋จผํธ ์ฌ์ฉ<properties> <org.springframework-version>5.3.25</org.springframework-version> <org.aspectj-version>1.9.19</org.aspectj-version> <org.slf4j-version>2.0.6</org.slf4j-version> </properties>
๐dependency : ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ์ผ์ ํ๋ก์ ํธ ๋น๋ ์ฒ๋ฆฌํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ
โ ์์กด๊ด๊ณ๋ก ์ค์ ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ์ผ๋ ์๋์ผ๋ก ๋น๋ ์ฒ๋ฆฌ
๐groupId : ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ์ผ์ ์ ๊ณตํ๋ ๊ทธ๋ฃน์ ์๋ณ์(๋๋ฉ์ธ)๋ฅผ ์ค์ ํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ
๐artifactId : ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ์ด๋ฆ(์๋ณ์)์ ์ค์ ํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ
๐version : ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋ฒ์ ์ ์ค์ ํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ
๐exclusions : exclusion ๋ชฉ๋ก์ ์ค์ ํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ
๐exclusion : ์์กด๊ด๊ณ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ค ์ ์ธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ค์ ํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ<dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${org.springframework-version}</version> <exclusions> <!-- Exclude Commons Logging in favor of SLF4j --> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </exclusion> </exclusions> </dependency>
๐pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd"> <!-- Maven : ๋น๋ ํด - ํ๋ก์ ํธ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๊ด๋ฆฌํ๋ ํ๋ก๊ทธ๋จ --> <!-- pom.xml : Maven ๋น๋ ํด์ ์ด์ฉํ์ฌ ํ๋ก์ ํธ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๋น๋ํ๊ธฐ ์ํ ์ ๋ณด๋ฅผ ์ ๊ณตํ๋ ํ๊ฒฝ์ค์ ํ์ผ --> <!-- โ ๋ก์ปฌ ์ ์ฅ์์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ์ผ์ ํ๋ก์ ํธ์ ๋น๋๋๋๋ก ์ฒ๋ฆฌ --> <!-- โ ๋ก์ปฌ ์ ์ฅ์์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ์ผ์ด ์๋ ๊ฒฝ์ฐ ๋ฉ์ด๋ธ ์ ์ฅ์์์ ๋ค์ด๋ก๋ ๋ฐ์ ๋ก์ปฌ ์ ์ฅ์์ ์ ์ฅ --> <!-- ๋ก์ปฌ ์ ์ฅ์(Local Repository) : ํ๋ก์ ํธ์ ๋น๋๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ์ผ์ ์ ์ฅํ๊ธฐ ์ํ ํด๋ --> <!-- โ ์ฌ์ฉ์ ํด๋์ .m2 ํด๋๋ฅผ ๋ก์ปฌ ์ ์ฅ์๋ก ์ฌ์ฉ --> <!-- ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ์ผ์ ๋ฌธ์ ๊ฐ ์๋ ๊ฒฝ์ฐ ์ดํด๋ฆฝ์ค ์ข ๋ฃ ํ .m2 ํด๋์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ์ผ์ ์ญ์ ํ๊ณ ์ดํด๋ฆฝ์ค ์ฌ์คํ --> <!-- ๋ฉ์ด๋ธ ์ ์ฅ์(Maven Repository) : ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ์ผ์ด ์ ์ฅ๋ ์ธํฐ๋ท์์ ์ ์ฅ์ --> <!-- โ https://mvnrepository.com ์ฌ์ดํธ ์ฐธ์กฐ --> <modelVersion>4.0.0</modelVersion> <groupId>xyz.itwill</groupId> <artifactId>controller</artifactId> <name>spring</name> <packaging>war</packaging> <version>1.0.0-BUILD-SNAPSHOT</version> <!-- properties : pom.xml ํ์ผ์์ ์์ฃผ ์ฌ์ฉํ๋ ๊ฐ์ ์ด๋ฆ(์๋ณ์)์ ์ด์ฉํ์ฌ ๋ฑ๋กํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ --> <!-- โ ํ์ ์๋ฆฌ๋จผํธ๋ช ์ด๋ฆ์ ๊ฐ์ ๊ตฌ๋ถํ๊ธฐ ์ํ ์๋ณ์๋ก ์ฌ์ฉํ๋ฉฐ ์๋ฆฌ๋จผํธ ๋ด์ฉ์ด ์ ๊ณต๋๋ ๊ฐ์ ํํ --> <!-- โ pom.xml ํ์ผ์์ ${์ด๋ฆ} ํ์์ผ๋ก ๊ฐ์ ์ ๊ณต๋ฐ์ ์ฌ์ฉ ๊ฐ๋ฅ --> <!-- โ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๋ฒ์ ์ ํจ์จ์ ์ผ๋ก ๊ด๋ฆฌํ๊ธฐ ์ํด properties ์๋ฆฌ๋จผํธ ์ฌ์ฉ --> <properties> <org.springframework-version>5.3.25</org.springframework-version> <org.aspectj-version>1.9.19</org.aspectj-version> <org.slf4j-version>2.0.6</org.slf4j-version> </properties> <!-- ======================================================================================================== --> <!-- dependencies : dependency ์๋ฆฌ๋จผํธ ๋ชฉ๋ก์ ์ค์ ํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ --> <dependencies> <!-- Spring --> <!-- dependency : ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ์ผ์ ํ๋ก์ ํธ ๋น๋ ์ฒ๋ฆฌํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ --> <!-- โ ์์กด๊ด๊ณ๋ก ์ค์ ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ์ผ๋ ์๋์ผ๋ก ๋น๋ ์ฒ๋ฆฌ --> <dependency> <!-- groupId : ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ์ผ์ ์ ๊ณตํ๋ ๊ทธ๋ฃน์ ์๋ณ์(๋๋ฉ์ธ)๋ฅผ ์ค์ ํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ --> <groupId>org.springframework</groupId> <!-- artifactId : ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ์ด๋ฆ(์๋ณ์)์ ์ค์ ํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ --> <artifactId>spring-context</artifactId> <!-- version : ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋ฒ์ ์ ์ค์ ํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ --> <version>${org.springframework-version}</version> <!-- exclusions : exclusion ๋ชฉ๋ก์ ์ค์ ํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ --> <exclusions> <!-- Exclude Commons Logging in favor of SLF4j --> <!-- exclusion : ์์กด๊ด๊ณ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ค ์ ์ธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ค์ ํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ --> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${org.springframework-version}</version> </dependency> <!-- ======================================================================================================== --> <!-- AspectJ --> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjrt</artifactId> <version>${org.aspectj-version}</version> </dependency> <!-- ======================================================================================================== --> <!-- Logging --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>${org.slf4j-version}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>jcl-over-slf4j</artifactId> <version>${org.slf4j-version}</version> <!-- scope : ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํ์ผ์ด ๋น๋๋์ด์ง๋ ๋ฒ์๋ฅผ ์ค์ ํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ --> <scope>runtime</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>${org.slf4j-version}</version> <scope>runtime</scope> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> <exclusions> <exclusion> <groupId>javax.mail</groupId> <artifactId>mail</artifactId> </exclusion> <exclusion> <groupId>javax.jms</groupId> <artifactId>jms</artifactId> </exclusion> <exclusion> <groupId>com.sun.jdmk</groupId> <artifactId>jmxtools</artifactId> </exclusion> <exclusion> <groupId>com.sun.jmx</groupId> <artifactId>jmxri</artifactId> </exclusion> </exclusions> <scope>runtime</scope> </dependency> <!-- ======================================================================================================== --> <!-- @Inject --> <dependency> <groupId>javax.inject</groupId> <artifactId>javax.inject</artifactId> <version>1</version> </dependency> <!-- ======================================================================================================== --> <!-- Servlet --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>4.0.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>javax.servlet.jsp-api</artifactId> <version>2.3.3</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <!-- ======================================================================================================== --> <!-- Test --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.13.2</version> <scope>test</scope> </dependency> <!-- ======================================================================================================== --> <!-- https://mvnrepository.com/artifact/xerces/xercesImpl --> <!-- => ๋ก๊ทธ ๊ตฌํ์ฒด๋ฅผ ์ด์ฉํ ๋ก๊น ์ ๋ณด ์ฒ๋ฆฌ์ ๊ฒฝ๋ก์ ๋ฌธ์ ๊ฐ ์๋ ๊ฒฝ์ฐ ํด๊ฒฐ๋ฐฉ๋ฒ์ ์ ๊ณตํ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ --> <dependency> <groupId>xerces</groupId> <artifactId>xercesImpl</artifactId> <version>2.12.2</version> </dependency> <!-- ======================================================================================================== --> <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-resources-plugin --> <!-- => Maven Plugin ๋ฌธ์ ์ pom.xml ํ์ผ์์ ์๋ฌ๊ฐ ๋ฐ์๋ ๊ฒฝ์ฐ ๋น๋ฆฌ ์ฒ๋ฆฌ์ ๋ํ ํด๊ฒฐ๋ฐฉ๋ฒ์ ์ ๊ณตํ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ --> <!-- <dependency> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>3.3.0</version> </dependency> --> </dependencies> <build> <plugins> <plugin> <artifactId>maven-eclipse-plugin</artifactId> <version>2.9</version> <configuration> <additionalProjectnatures> <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature> </additionalProjectnatures> <additionalBuildcommands> <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand> </additionalBuildcommands> <downloadSources>true</downloadSources> <downloadJavadocs>true</downloadJavadocs> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.5.1</version> <configuration> <source>1.6</source> <target>1.6</target> <compilerArgument>-Xlint:all</compilerArgument> <showWarnings>true</showWarnings> <showDeprecation>true</showDeprecation> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.2.1</version> <configuration> <mainClass>org.test.int1.Main</mainClass> </configuration> </plugin> </plugins> </build> </project>
๐appender : ๋ก๊ทธ ๊ตฌํ์ฒด์ ๋ํ ํด๋์ค๋ฅผ ์ค์ ํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ
๐name ์์ฑ : appender ์๋ฆฌ๋จผํธ๋ฅผ ๊ตฌ๋ถํ๊ธฐ ์ํ ์๋ณ์๋ฅผ ์์ฑ๊ฐ์ผ๋ก ์ค์
๐class ์์ฑ : ๋ก๊ทธ ๊ตฌํ์ฒด๋ก ์ฌ์ฉํ๊ธฐ ์ํ ํด๋์ค๋ฅผ ์์ฑ๊ฐ์ผ๋ก ์ค์
โ class ์์ฑ๊ฐ์ผ๋ก ์ค์ ๋ ํด๋์ค์ ๋ฐ๋ผ ๋ก๊น ์ ๋ณด๋ฅผ ๊ธฐ๋กํ๋ ๋ฐฉ์์ด ๋ค๋ฅด๊ฒ ์ค์
โ class ์์ฑ๊ฐ์ผ๋ก ์ค์ ๋ ํด๋์ค๋ ๋ฐ๋์ Appender ์ธํฐํ์ด์ค๋ฅผ ์์๋ฐ์ ์์ฑ๐ConsoleAppender ํด๋์ค : ๋ก๊น ์ ๋ณด๋ฅผ ์๋ฒ ์ฝ์์ ๊ธฐ๋กํ๊ธฐ ์ํ ํด๋์ค
๐param : Appender ํด๋์ค์ ํ์ํ ๊ฐ์ ์ ๊ณตํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ
๐layout : ๋ก๊น ์ ๋ณด๋ฅผ ์ ๊ณต๋ฐ์ ๋ก๊ทธ ํ์์ ์ค์ ํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ
๐class ์์ฑ : ๋ก๊ทธ ํ์ ๊ด๋ จ ์ ๋ณด๋ฅผ ์ ๊ณตํ๊ธฐ ์ํ ํด๋์ค๋ฅผ ์์ฑ๊ฐ์ผ๋ก ์ค์
โ PatternLayout ํด๋์ค : ๋ก๊ทธ ํ์์ ์์ฑํ๊ธฐ ์ํ ๋ณํ ๋ฌธ์๋ฅผ ์ ๊ณตํ๋ ํด๋์ค๐ก ๋ณํ๋ฌธ์(Conversion Character) - ๋ณํ๋ฌธ์๋ ์ผ๋ฐ๋ฌธ์์ ๊ตฌ๋ถํ๊ธฐ ์ํด % ๊ธฐํธ๋ก ์์
๐%c : ํจํค์ง๊ฐ ํฌํจ๋ ํด๋์ค์ ์ด๋ฆ์ ๊ธฐ๋ก - {์ ์๊ฐ}์ ์ด์ฉํ์ฌ ์ํ๋ ํ์์ผ๋ก ๊ธฐ๋ก ๊ฐ๋ฅ
โ %c{1} : ํจํค์ง๋ฅผ ์ ์ธํ ํด๋์ค์ ์ด๋ฆ๋ง ๊ธฐ๋ก
๐%d : ๋ ์ง์ ์๊ฐ์ ๊ธฐ๋ก - {SimpleDateFormat}์ ์ด์ฉํ์ฌ ์ํ๋ ํ์์ผ๋ก ๊ธฐ๋ก
โ %d{yyyy-MM-dd} : [๋ -์-์ผ] ํ์์ผ๋ก ๋ก๊ทธ์๊ฐ ๊ธฐ๋ก
๐%m : ๋ก๊ทธ ์ด๋ฒคํธ์ ์ํด ์์ฑ๋ ๋ก๊ทธ ๋ฉ์ธ์ง๋ฅผ ๊ธฐ๋ก
๐%n : ์ํฐ(Enter)๋ฅผ ๊ธฐ๋ก - ๋ก๊ทธ ์ค๋ฐ๊ฟ
๐%M : ๋ก๊ทธ ์ด๋ฒคํธ๊ฐ ๋ฐ์๋ ๋ฉ์๋์ ์ด๋ฆ์ ๊ธฐ๋ก
๐%p : ๋ก๊ทธ ๋ฉ์ธ์ง๊ฐ ๋ฐ์๋ ๋ก๊ทธ ์ด๋ฒคํธ ๊ธฐ๋ก
โ ๋ก๊ทธ ์ด๋ฒคํธ : TRACE > DEBUG > INFO > WARN > ERROR > FATAL
๐ก ๋ณํ๋ฌธ์ ์๋ฆฟ์ ์ค์ - %p ๋ณํ๋ฌธ์๋ฅผ ์ด์ฉํ์ฌ ์์ ์ค์
๐%p : ๋ก๊ทธ ์ด๋ฒคํธ์ ๊ธธ์ด๋งํผ ์๋ฆฟ์๋ฅผ ์ ๊ณต๋ฐ์ ๊ธฐ๋ก
๐%5p : ๋ก๊ทธ ์ด๋ฒคํธ๋ฅผ 5์๋ฆฌ(์ต๋ ์๋ฆฟ์)๋ฅผ ์ ๊ณต๋ฐ์ ๊ธฐ๋ก - ์ค๋ฅธ์ชฝ ์ ๋ ฌ
โ ์๋ฆฟ์๊ฐ ๋ถ์กฑํ๋ฉด ๊ธฐ๋ก์ด ์๋ฆฌ๊ณ ๋จ์ผ๋ฉด ๊ณต๋ฐฑ์ผ๋ก ์ฒ๋ฆฌ๋์ด ๊ธฐ๋ก
๐%-5p : ๋ก๊ทธ ์ด๋ฒคํธ๋ฅผ 5์๋ฆฌ(์ต๋ ์๋ฆฟ์)๋ฅผ ์ ๊ณต๋ฐ์ ๊ธฐ๋ก - ์ผ์ชฝ ์ ๋ ฌ
๐%.5p : ๋ก๊ทธ ์ด๋ฒคํธ๋ฅผ 5์๋ฆฌ(์ต์ ์๋ฆฟ์)๋ฅผ ์ ๊ณต๋ฐ์ ๊ธฐ๋ก - ์ค๋ฅธ์ชฝ ์ ๋ ฌ<appender name="console" class="org.apache.log4j.ConsoleAppender"> <param name="Target" value="System.out" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%-5p: %c - %m%n" /> </layout> </appender>
๐log4j.xml
<?xml version="1.0" encoding="UTF-8"?> <!-- log4j.xml : ๋ก๊ทธ ๊ตฌํ์ฒด์ ๋ํ ํ๊ฒฝ์ค์ ํ์ผ --> <!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> <!-- ======================================================================================================== --> <!-- Appenders --> <!-- appender : ๋ก๊ทธ ๊ตฌํ์ฒด์ ๋ํ ํด๋์ค๋ฅผ ์ค์ ํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ --> <!-- name ์์ฑ : appender ์๋ฆฌ๋จผํธ๋ฅผ ๊ตฌ๋ถํ๊ธฐ ์ํ ์๋ณ์๋ฅผ ์์ฑ๊ฐ์ผ๋ก ์ค์ --> <!-- class ์์ฑ : ๋ก๊ทธ ๊ตฌํ์ฒด๋ก ์ฌ์ฉํ๊ธฐ ์ํ ํด๋์ค๋ฅผ ์์ฑ๊ฐ์ผ๋ก ์ค์ --> <!-- โ class ์์ฑ๊ฐ์ผ๋ก ์ค์ ๋ ํด๋์ค์ ๋ฐ๋ผ ๋ก๊น ์ ๋ณด๋ฅผ ๊ธฐ๋กํ๋ ๋ฐฉ์์ด ๋ค๋ฅด๊ฒ ์ค์ --> <!-- โ class ์์ฑ๊ฐ์ผ๋ก ์ค์ ๋ ํด๋์ค๋ ๋ฐ๋์ Appender ์ธํฐํ์ด์ค๋ฅผ ์์๋ฐ์ ์์ฑ --> <!-- ConsoleAppender ํด๋์ค : ๋ก๊น ์ ๋ณด๋ฅผ ์๋ฒ ์ฝ์์ ๊ธฐ๋กํ๊ธฐ ์ํ ํด๋์ค --> <appender name="console" class="org.apache.log4j.ConsoleAppender"> <!-- param : Appender ํด๋์ค์ ํ์ํ ๊ฐ์ ์ ๊ณตํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ --> <param name="Target" value="System.out" /> <!-- layout : ๋ก๊น ์ ๋ณด๋ฅผ ์ ๊ณต๋ฐ์ ๋ก๊ทธ ํ์์ ์ค์ ํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ --> <!-- class ์์ฑ : ๋ก๊ทธ ํ์ ๊ด๋ จ ์ ๋ณด๋ฅผ ์ ๊ณตํ๊ธฐ ์ํ ํด๋์ค๋ฅผ ์์ฑ๊ฐ์ผ๋ก ์ค์ --> <!-- โ PatternLayout ํด๋์ค : ๋ก๊ทธ ํ์์ ์์ฑํ๊ธฐ ์ํ ๋ณํ ๋ฌธ์๋ฅผ ์ ๊ณตํ๋ ํด๋์ค --> <!-- โ ๋ณํ๋ฌธ์(Conversion Character) - ๋ณํ๋ฌธ์๋ ์ผ๋ฐ๋ฌธ์์ ๊ตฌ๋ถํ๊ธฐ ์ํด % ๊ธฐํธ๋ก ์์ --> <!-- %c : ํจํค์ง๊ฐ ํฌํจ๋ ํด๋์ค์ ์ด๋ฆ์ ๊ธฐ๋ก - {์ ์๊ฐ}์ ์ด์ฉํ์ฌ ์ํ๋ ํ์์ผ๋ก ๊ธฐ๋ก ๊ฐ๋ฅ --> <!-- โ %c{1} : ํจํค์ง๋ฅผ ์ ์ธํ ํด๋์ค์ ์ด๋ฆ๋ง ๊ธฐ๋ก --> <!-- %d : ๋ ์ง์ ์๊ฐ์ ๊ธฐ๋ก - {SimpleDateFormat}์ ์ด์ฉํ์ฌ ์ํ๋ ํ์์ผ๋ก ๊ธฐ๋ก --> <!-- โ %d{yyyy-MM-dd} : [๋ -์-์ผ] ํ์์ผ๋ก ๋ก๊ทธ์๊ฐ ๊ธฐ๋ก --> <!-- %m : ๋ก๊ทธ ์ด๋ฒคํธ์ ์ํด ์์ฑ๋ ๋ก๊ทธ ๋ฉ์ธ์ง๋ฅผ ๊ธฐ๋ก --> <!-- %n : ์ํฐ(Enter)๋ฅผ ๊ธฐ๋ก - ๋ก๊ทธ ์ค๋ฐ๊ฟ --> <!-- %M : ๋ก๊ทธ ์ด๋ฒคํธ๊ฐ ๋ฐ์๋ ๋ฉ์๋์ ์ด๋ฆ์ ๊ธฐ๋ก --> <!-- %p : ๋ก๊ทธ ๋ฉ์ธ์ง๊ฐ ๋ฐ์๋ ๋ก๊ทธ ์ด๋ฒคํธ ๊ธฐ๋ก --> <!-- โ ๋ก๊ทธ ์ด๋ฒคํธ : TRACE > DEBUG > INFO > WARN > ERROR > FATAL --> <!-- โ ๋ณํ๋ฌธ์ ์๋ฆฟ์ ์ค์ - %p ๋ณํ๋ฌธ์๋ฅผ ์ด์ฉํ์ฌ ์์ ์ค์ --> <!-- %p : ๋ก๊ทธ ์ด๋ฒคํธ์ ๊ธธ์ด๋งํผ ์๋ฆฟ์๋ฅผ ์ ๊ณต๋ฐ์ ๊ธฐ๋ก --> <!-- %5p : ๋ก๊ทธ ์ด๋ฒคํธ๋ฅผ 5์๋ฆฌ(์ต๋ ์๋ฆฟ์)๋ฅผ ์ ๊ณต๋ฐ์ ๊ธฐ๋ก - ์ค๋ฅธ์ชฝ ์ ๋ ฌ --> <!-- โ ์๋ฆฟ์๊ฐ ๋ถ์กฑํ๋ฉด ๊ธฐ๋ก์ด ์๋ฆฌ๊ณ ๋จ์ผ๋ฉด ๊ณต๋ฐฑ์ผ๋ก ์ฒ๋ฆฌ๋์ด ๊ธฐ๋ก --> <!-- %-5p : ๋ก๊ทธ ์ด๋ฒคํธ๋ฅผ 5์๋ฆฌ(์ต๋ ์๋ฆฟ์)๋ฅผ ์ ๊ณต๋ฐ์ ๊ธฐ๋ก - ์ผ์ชฝ ์ ๋ ฌ --> <!-- %.5p : ๋ก๊ทธ ์ด๋ฒคํธ๋ฅผ 5์๋ฆฌ(์ต์ ์๋ฆฟ์)๋ฅผ ์ ๊ณต๋ฐ์ ๊ธฐ๋ก - ์ค๋ฅธ์ชฝ ์ ๋ ฌ --> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%-5p: %c - %m%n" /> </layout> </appender> <!-- ======================================================================================================== --> <!-- Application Loggers --> <!-- logger : ํน์ ํจํค์ง์ ํด๋์ค์์ ๋ฐ์๋๋ ๋ก๊ทธ ์ด๋ฒคํธ๋ฅผ ๊ธฐ๋กํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ --> <!-- name ์์ฑ : ํจํค์ง ๊ฒฝ๋ก๋ฅผ ์์ฑ๊ฐ์ผ๋ก ์ค์ --> <logger name="xyz.itwill.controller"> <!-- level : ํจํค์ง์ ์์ฑ๋ ํด๋์ค์์ ๋ฐ์๋๋ ๋ก๊ทธ ์ด๋ฒคํธ๋ฅผ ์ค์ ํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ --> <level value="info" /> </logger> <!-- --> <!-- 3rdparty Loggers --> <logger name="org.springframework.core"> <level value="info" /> </logger> <!-- --> <logger name="org.springframework.beans"> <level value="info" /> </logger> <!-- --> <logger name="org.springframework.context"> <level value="info" /> </logger> <!-- --> <logger name="org.springframework.web"> <level value="info" /> </logger> <!-- ======================================================================================================== --> <!-- Root Logger --> <!-- root : ๋ชจ๋ ํด๋์ค์์ ๋ฐ์๋๋ ๋ก๊ทธ ์ด๋ฒคํธ๋ฅผ ๊ธฐ๋กํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ --> <!-- โ ๋ชจ๋ logger ์๋ฆฌ๋จผํธ๋ root ์๋ฆฌ๋จผํธ์ ์ ๋ณด๋ฅผ ์์๋ฐ์ ์ฌ์ฉ --> <root> <!-- priority : ๋ชจ๋ ํด๋์ค์์ ๋ฐ์๋๋ ๊ธฐ๋ณธ ๋ก๊ทธ ์ด๋ฒคํธ๋ฅผ ์ค์ ํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ --> <!-- value ์์ฑ : ๋ก๊ทธ ์ด๋ฒคํธ๋ฅผ ์์ฑ๊ฐ์ผ๋ก ์ค์ --> <!-- โ ์์ฑ๊ฐ์ผ๋ก ์ค์ ๋ ๋ก๊ทธ ์ด๋ฒคํธ๋ณด๋ค ์์์ ์ด๋ฒคํธ๊ฐ ๋ฐ์๋ ๊ฒฝ์ฐ ๋ก๊ทธ ๊ตฌํ์ฒด๋ก ๊ธฐ๋ก --> <priority value="warn" /> <!-- appender-ref : ๋ก๊ทธ ๊ตฌํ์ฒด๋ฅผ ์ฐธ์กฐํ๊ธฐ ์ํ ์๋ฆฌ๋จผํธ --> <!-- ref ์์ฑ : appender ์๋ฆฌ๋จผํธ์ ์๋ณ์๋ฅผ ์์ฑ๊ฐ์ผ๋ก ์ค์ --> <appender-ref ref="console" /> </root> </log4j:configuration>