Announcement Announcement Module
Collapse
No announcement yet.
spring configure log4j catch22 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring configure log4j catch22

    I want to create a runnable jar that I can execute like so:

    java -Dprops.file=app.props -jar App.jar

    packaged in the jar at /src are the log4j config and the context.xml

    in props.file I want to have properties like so:
    log.file=C:/foo.log
    smtp.host=hostname
    smtp.to=[email protected],[email protected]

    and I want to use those properties to configure log4j.

    unless I use -D args when I start up the app, I seem to run into a catch22 because Spring wants to use the logger when the context starts up.

    I used the PropertyPlaceHolder so I can use ${some.prop} from within the context.xml file, but if I try to reset the log4j config with a new config that uses ${log.file}....it won't be evaluated correctly. Basically, using PPH it appears you can only use variables in the xml context, but not in another config file....like log4j.

    how are other getting around that?

    I just used my main method to export every property found in the app.props file as a system prop. Then anybody can use it....spring or log4j. This seems to make PPH worthless though...which seems "wrong"
Working...
X