I want to do two things:
Console logging seems to work just
Summary others (@basiljames, @daker, @Jay Taylor) answers here:
log4j2.xml Configurationmy case:
log4j2 version: 2.13.0
log4j2.xml configuration:
%d{yyyyMMdd HH:mm:ss} %-5p [%t] %C{2} %F%L - %m%n
A: as official doc also mentioned, the core part:
can achieve:
based on:
DEBUGset:
File level to DEBUGConsole level to INFO@Stealth Rabbi: so what was the problem?A: original main problem is:
that is name="filelogger" in:
for normally the logger name is your class name, like
another possible minor problem is:
error, so file created but emptywhen set file level to error, but your log code is low level, such as
logger.debug("output something");
that is:
logger lever in code(debug) < file level(error)
so debug content will NOT output to log file, log file keep empty.
@Bendemann is it possible to specify a path where I want to save the file if I am running a war file on a tomcat server?A: yes. Just set the relative or absolute log file path to File's fileName.
just like:
...
is ok.