first, the introduction of JAR package
Gralde Project
Compile ' log4j:log4j:1.2.17 '
compile ' commons-logging:commons-logging:1.2 '
Maven Project
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId> commons-logging</groupid>
<artifactId>commons-logging</artifactId>
<version> 1.2</version>
</dependency>
General items
Directly into the jar file, add to the project directory can
Second, add log4j.properties configuration file
Gradle/maven Project creates log4j.properties in the resources directory
Common items Create log4j.properties in the same sibling directory of the package
Log4j.properties Simple example below
Log4j.rootlogger=debug,console
# Applies to console
Log4j.appender.console=org.apache.log4j.consoleappender
Log4j.appender.threshold=debug
log4j.appender.console.target=system.out
log4j.appender.console.layout= Org.apache.log4j.PatternLayout
Log4j.appender.console.layout.conversionpattern=[%-12d{hh\:mm\:ss. SS}] [%p]%l%m%n
More configuration can refer to the configuration and use of log4j three, use the way
public class Resourcecontentutil {
private static final Logger log = Logger.getlogger (Resourcecontentutil.class) C9/>public static void Main (string[] args) {
log.info ("Hello world!")
}
}
Specific source please refer to: GitHub Project Io.resource Module