Reputation: 6091
I have start working with spring boot and gradle and I am trying to use log4j2 for logging. I am first compiling and building:
gradlew clean build
and after than execute jar:
java -jar build/libs/java-apns-notifier-0.1.0.jar
After executing jar I can see log in the console but not in the file mentioned in log4j2.xml(D:/temp/logs/apns.log). In that file I can see only logs from springframework but not from my code.
Question is how to make this simple scenario to work?
I want to see that my logs also appears in the log file.
Here is the source code: Java Apple Push Notification Service Notifier
IMPORTANT!
I have recently noticed that logs appears. But only after I kill the process.
So to clarify here is what is going on:
java -jar build/libs/java-apns-notifier-0.1.0.jar
-> Nothing appears in the log file
Upvotes: 0
Views: 1299
Reputation: 671
The log is taking some time to appear in your log file because you are using
immediateFlush="false"
If you switch it to true, you will see the logs appearing immediately, but it might impact the performance of the application.
By default, bufferedIO is true and bufferSize is 8192 bytes. This means that the logs will only be written to disk after the buffer has 8192 chars.
Refer to https://logging.apache.org/log4j/2.x/manual/appenders.html for more details.
Upvotes: 1