0

I am working on the JUL - Log4j 1.x bridge. I was follow this steps https://stackoverflow.com/a/4318607. Everything work fine, when I using VM argument:

-Djava.util.logging.manager=org.apache.logging.julbridge.JULBridgeLogManager

But I can't using VM arguments, it is some way how to set this classpath like static variable? For in exmple in Main.class

Or somehow set java.util.logging.manager (LogManager class) to JULBridgeLogManager

Sepi
  • 77
  • 5
  • 1
    You can set system properties with `System.setProperty` **but** it varies a lot *when* those properties are read. I don't know if that specific property will be read/interpreted before execution reaches your main class. If it is, then setting it won't have any observable effect. – Joachim Sauer Mar 23 '22 at 10:25
  • @JoachimSauer I will try, but when I want set my logging manager it will be System.setProperty("java.util.logging.manager", "org.apache.logging.julbridge.JULBridgeLogManager"); Or I must somehowe create property? – Sepi Mar 23 '22 at 10:54
  • Yes, that would be it. There's no distinction between setting and creating. – Joachim Sauer Mar 23 '22 at 10:57
  • @JoachimSauer this is not working for me. – Sepi Mar 23 '22 at 11:05
  • then the property is apparently read before your code is reached. Seems you need to figure out how to set the system property from the command line after all. – Joachim Sauer Mar 23 '22 at 11:20
  • There must be the way how to do in code :/ – Sepi Mar 23 '22 at 11:34
  • Must there? I'm not sure, but you do you. – Joachim Sauer Mar 23 '22 at 11:39
  • @JoachimSauer it is solved. I did put System.setProperty(...) to the static block and worked well. Thank you for your advice. – Sepi Mar 23 '22 at 12:41

1 Answers1

0

I used in Main class static block and delete VM arguments and that worked well:

static {
    System.setProperty("java.util.logging.manager", "org.apache.logging.julbridge.JULBridgeLogManager");
}
Sepi
  • 77
  • 5