Log4J change File path dynamically

前端 未结 1 1371
我在风中等你
我在风中等你 2020-12-29 10:01

I want to change the path and file name of my log4j logfile dynamically.

I have read a lot of pages and nearly every tell me that I should use system properties like

相关标签:
1条回答
  • 2020-12-29 10:42

    I think you meant "my.log" not "{my.log"

    System.setProperty("my.log", "C:/logfile.log");
    

    I wouldn't imagine you can change this once the logging has started so you need to set this as early in your program as possible.

    BTW: You can sub-class FileAppender to make it behave any way you like.

    | improve this answer | |
    0 讨论(0)
提交回复
热议问题