Skip to content
Advertisement

Why Log4j2 doesn’t write logs to a file?

This is my configuration log4j2.xml with path to filesrc/com/tarasiuk/task_01/log/dataLogger.log:

JavaScript

Structure of my project:
enter image description here

What I do:

  1. change path to log file from src/com/tarasiuk/task_01/log/dataLogger.log to com/tarasiuk/task_01/log/dataLogger.log – no result.
  2. change level in <Logger> from debug to info – no result.

Logs are output to the console – that ok. But why Log4j2 doesn’t write logs to a file?

Advertisement

Answer

Try with below appender.

May be in your case it is not able to get path from property, so i had provided only name. So automatically it will create file on same path as your application is.

JavaScript

This will help you.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement