Proper way to include log4j in an Eclipse 4 (RCP/SWT/OSGi) application

后端 未结 3 1676
走了就别回头了
走了就别回头了 2021-01-28 16:53

This is a follow-up (somehow of my Third-party dependencies to an OSGi application) where it was suggested that some libraries e.g. log4j are already available as bundl

3条回答
  •  囚心锁ツ
    2021-01-28 17:22

    If you really need to expose the file, you could put it anywhere you want, and then make sure your program calls one of these methods at startup:

    • org.apache.log4j.xml.DOMConfigurator.configure(String filename)
    • org.apache.log4j.PropertyConfigurator.configure(String configFilename)

    Or use the "configureAndWatch"-variants if you would like to make changes to the config without restarting your application.

    Edit: I write "If you really need to", because I have experienced that I never need to turn on debug-logging after deployment, because it is always turned on! This is OK for applications where I have normal (but not extreme) requirements on response-time and throughput. Logging to an UDP-appender is fast (and does not fill up the disk). Or using rolling file appender is quite safe, and fast enough for my use. Always having the debug-log available is a life-saver when nailing down those hard-to-reproduce bugs.

提交回复
热议问题