how to change the log4j log file dynamically?

前端 未结 2 1761
-上瘾入骨i
-上瘾入骨i 2021-01-13 13:51

I want to have a log4j configuration such that the log file name should have like ${System-name}log.log. that is if the application is launched on any system then without ch

2条回答
  •  野的像风
    2021-01-13 14:32

    You can use Java system properties with the ${property} syntax. There are number of system properties that are defined by default including

    "os.arch"     Operating system architecture
    "os.name"     Operating system name
    "os.version"  Operating system version
    

    For a full list of default properties see API of System or list them with System.getProperties().list(System.out).

    If the default properties won't do then you'll have top add your own properties using System.setProperty(property, value).

提交回复
热议问题