I have a pretty simple Java application that is distributed to users as an executable JAR file. To track usage and help with diagnostics, I want to add logging capabilities to the application, but from one execution to the next I will never be sure where this application will run.
To do this, I configured the application to use the log4j loader application - no matter where the user starts this application, messages are sent to the socket and correctly logged, which is ideal.
What I am currently using is that I would prefer to use different log4j configurations when I run locally and when I deploy this application to production. When running locally (from my IDE, IntelliJ), I would prefer to use the console appender for several reasons:
- It is trivial to see what happens.
- Should I develop without an Internet connection, I donβt want to depend on the impossibility of connecting.
- I don't want to clutter up production logs with what I do during development.
When I pack the application and distribute it, I would like it to use a socket application, not a console appender.
Is there any easy way to accomplish what I want? I use Maven to build my application, but I'm not very skilled with it.
source share