Commit f069a80d authored by Dr. Martin Goik's avatar Dr. Martin Goik

Using log4j 2.x branch

parent acbf1e93
......@@ -4,7 +4,7 @@
<groupId>de.hdm-stuttgart.mi</groupId>
<artifactId>mi-maven-archetype-quickstart</artifactId>
<version>1.0</version>
<version>1.2</version>
<packaging>jar</packaging>
</project>
......@@ -24,9 +24,14 @@
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.1</version>
</dependency>
</dependencies>
......
......@@ -12,6 +12,8 @@ public class App {
public static void main( String[] args ) {
System.out.println( "Hello World!" );
log.debug("With respect to logging you may want to configure file");
log.debug("'src/main/resources/log4j.properties' to suit your needs.");
log.debug("'src/main/resources/log4j2.xml' to suit your needs.");
log.debug("Above config file 'log4j2.xml' will result in 'A1.log'" +
"file creation containing similar logging output as well.");
}
}
#Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=DEBUG, A1
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
# A1 uses PatternLayout comforting Eclipse's debugger.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%p: %m at %c.%M(%C{1}.java:%L)%n
# Activate per-class or package logging rules if required. For example
# reducing logging to INFO level for class ${groupId}.${artifactId}.App
# can be achieved by un-commenting the following line:
#log4j.logger.${groupId}.${artifactId}.App.parse.Group=INFO
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<File name="A1" fileName="A1.log" append="false">
<PatternLayout pattern="%t %-5p %c{2} - %m%n"/>
</File>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>
</Console>
</Appenders>
<Loggers>
<Logger name="org.apache.log4j.xml" level="debug">
<AppenderRef ref="A1"/>
</Logger>
<Root level="debug">
<AppenderRef ref="STDOUT"/>
</Root>
</Loggers>
</Configuration>
<!--
# Activate per-class or package logging rules if required. For example
# reducing logging to INFO level for class ${groupId}.${artifactId}.App
# can be achieved by un-commenting the following line:
#log4j.logger.${groupId}.${artifactId}.App.parse.Group=INFO
-->
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment