BAEL-5677 - Logging to both file and console with log4j (#12550)
* BAEL-5677 - Logging to both file and console with log4j * Moving from log4j to log4j2 * Correction in class name * Moving to log4j2 package
This commit is contained in:
parent
ff63982af2
commit
72409da627
|
@ -0,0 +1,14 @@
|
|||
package com.baeldung.logging.log4j2.consoleandfile;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class Log4j2ConsoleAndFile {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(Log4j2ConsoleAndFile.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
logger.info("Hello World!");
|
||||
logger.debug("Hello World!");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
appender.console.type = Console
|
||||
appender.console.name = STDOUT
|
||||
appender.console.layout.type = PatternLayout
|
||||
appender.console.layout.pattern = [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n
|
||||
|
||||
appender.file.type = File
|
||||
appender.file.name = LOGFILE
|
||||
appender.file.fileName=logs/log4j.log
|
||||
appender.file.layout.type=PatternLayout
|
||||
appender.file.layout.pattern=[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n
|
||||
appender.file.filter.threshold.type = ThresholdFilter
|
||||
appender.file.filter.threshold.level = info
|
||||
|
||||
rootLogger=debug, STDOUT, LOGFILE
|
Loading…
Reference in New Issue