I'm using java.util.logging for logging and tracing purposes. How can I within a Java application dynamically set the file to which the log should be written.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
Are you talking about JULog?
If so, the answer is "you can't". In order to change what file you're logging to (or change anything else in configuration) you need to know what underlying logging implementation you are using and the whole point of using JULog (quite arguable, btw, unless you're developing a library) is to not have ANY ties to logging implementations.
If selecting a file at runtime is a requirement you're likely going to be better off going with a concrete implementation like Log4j.
The
java.util.logging.FileHandler
might do its job for you. The following code snippet shows a simple example how to do set the logging destination programmatically: