Re: Best Practices - Properties files
Re: Best Practices - Properties files
- Subject: Re: Best Practices - Properties files
- From: Tim Worman <email@hidden>
- Date: Thu, 25 Jun 2009 09:26:41 -0700
There's a lot of good stuff in there. Thanks for offering up some of
your approaches. log4j is also something I have not really gotten
into. I use a lot of System.out when I'm diagnosing problems. :-)
T
On Jun 25, 2009, at 4:41 AM, Kieran Kelleher wrote:
Keep in mind that all of this Properties configuration stuff is more
or less provided by Project Wonder, so your wiki page should be in
the Project Wonder section (perhaps "Introduction to Wonder
Properties").
OK, here are a few more bits and pieces that you may or may not know
about.
The use of Properties.<user.name> is not only useful for basic
development and deployment configurations, but is ideal for teams of
developers where each developer has his/her own Properties file for
development since they may be working from different locations with
different database auth, smtp servers and logging settings, etc.
Also, note that Properties.<user.name> can be used to add additional
properties *or* to override stuff in the main Properties.
Be careful about over-use or abuse of the @@ template stuff though,
it can get confused when the logic stretches across multiple
Properties files.
For example in a Properties.<user.name> file I may have sth like:
smtpserver=smtp.somedomain.com
and in the main Properties file I might have multiple other
properties in various places in the Properties file that pick up
that single setting depending on which user.name config is in use,
for example:
log4j.appender.myMail.SMTPHost=@@smtpserver@@
er.javamail.smtpHost=@@smtpserver@@
WOSMTPHost=@@smtpserver@@
Another Wonder Properties feature is that all of your log4j settings
can be configured in a Properties file, which is ideal for user and
deployment specific logging configuration.
For example the base loggers config in my main Properties file in
one app I have looks like this. And some line items such as
log4j.rootLogger, log4j.appender.myMail.To are defined in each user
Properties file (Properties.deploy, Properties.kieran, etc.). Notice
the use of @@ substitution in properties such as
log4j.appender.A2.file, log4j.appender.myMail.SMTPHost,
log4j.appender.myMail.Subject.
In the Properties.kieran file, I might have log4j.rootLogger= INFO, A1
<snip - sample from main Properties>
# Pattern codes:
# %-5p : Priority DEBUG, INFO, WARN, etc.
# %d(ISO08601 : Date and time
# %t : Thread
# %c : Logger name (usually a class name)
# %m%n : Log message arguments
# Available levels are DEBUG, INFO, WARN, ERROR, FATAL
# log4j appender and formatting
# log4j.rootLogger= WARN, A1 A2, myMail
log4j.loggerFactory=er.extensions.logging.ERXLogger$Factory
# A1 is a ConsoleAppender
log4j.appender.A1=er.extensions.logging.ERXConsoleAppender
log4j.appender.A1.layout=er.extensions.logging.ERXPatternLayout
#log4j.appender.A1.layout.ConversionPattern=%-5p %d{HH:mm:ss} (%-20c:
%L) %x -%m%n
log4j.appender.A1.layout.ConversionPattern=%r %-5p [%t] (%C{3}, %M,
%L) - %n%m%n%n
# A2 is a DailyRollingFileAppender
log4j.appender.A2=org.apache.log4j.DailyRollingFileAppender
log4j.appender.A2.file=/var/log/webobjects_apps/
@@build.app.bundle.name@@-@@WOPort@@.log
log4j.appender.A2.datePattern='.'yyyy-MM-dd
log4j.appender.A2.append=true
log4j.appender.A2.layout=er.extensions.logging.ERXPatternLayout
log4j.appender.A2.layout.ConversionPattern=%-5p %d{ISO8601} [%t]
(%c: %L) - %m%n
# myMail is the SMTPAppender
log4j.appender.myMail=org.apache.log4j.net.SMTPAppender
log4j.appender.myMail.Threshold=ERROR
log4j.appender.myMail.BufferSize=10
## See deploy/development scenario for this since I want emails to
me for dev especially selenium tests
# log4j.appender.myMail.To=email@hidden,email@hidden
log4j.appender.myMail.From=email@hidden
log4j.appender.myMail.SMTPHost=@@smtpserver@@
log4j.appender.myMail.Subject=Log4J Error (@@build.app.bundle.name@@
host @@host@@ port @@WOPort@@)
log4j.appender.myMail.layout=er.extensions.logging.ERXPatternLayout
log4j.appender.myMail.layout.ConversionPattern=%r %-5p %d{ISO8601}%n
%n%V{t total/u used/f free}%n%n[%t] %n%n (%C, %M, %F:%L) - %n%n%m%n
</snip>
Tim, hope that gives you enough bits and pieces to start a wiki
page. Also, if you are not working with Wonder source you should
be .... a lot of good education in that there source code. Check out
the ERXProperties.java class to learn more about Properties in Wonder.
Regards, Kieran
On Jun 25, 2009, at 1:16 AM, Tim Worman wrote:
Keiran:
Thanks - there's some awesome options in there that I didn't know
about! I forgot to mention the one I was actually using in dev and
that is ~/WebObjects.properties but that one is pretty well
documented. I really like that one for using special dev passwords
and keeping it safely tucked away.
On Jun 24, 2009, at 7:17 PM, Kieran Kelleher wrote:
As you saw u can use Properties.<username> for specific user
configurations. This same feature can be used for configurations
too, for example have a deployment config file named
Properties.deploy and then in the WOMonitor args, simply put
-Duser.name=deploy
OK - I get this now. I'd misunderstood. It's actually using the
username variant and passing that in as a launch argument. I guess
you'd want to make sure you'd deployed a secure version of
WOMonitor as well. I haven't. :-( Still running "stock parts" with
that.
For sensitive passwords that you want kept out of svn repository,
you can put them in WOMonitor args directly like
-DMyEOModel.password = mypassword
OR use @@ template substitution and in WOMonitor args, put this:
-Duser.name=deploy
-Dsecretpassword=mypassword
and in Properties.deploy you can use a wonder simple template
format like this which does property resolving/substitution
MyEOModel.password = @@secretpassword@@
I love this option! I may have to really look at this option
further. I would not have been familiar enough
For *most* properties, see the file ERExtensions/Resources/
Properties. In fact the Resources/Properties file of each Wonder
framework usually documents the Properties that can be configured.
Also a new Wonder project in WOLips will usually have recommended
property settings. Browsing the source code of Wonder can
sometimes lead you to discover configurable properties that are
not documented anywhere too.
I figured I could probably jump into the ERXConfigurationManager
source to find any db connection options I was missing - but
unfortunately what's really been missing is the time to do
that. :-) I did look up the API and found that there were OpenBase
specific options but I stuck with DB.URL since I wasn't able to get
those working.
Useless Side Note: Googling "ERXConfigurationManager" returns the
Wonder 2.0 API as the first hit and actually does not return the
current API as any hit. :-) I've noticed this with other Wonder
class searches too. I "Wonder" if there's something we can do about
that?
Deployment scripts generally take the split tar.gz's created by
the standard build.xml and scp them to a remote server using ssh
where dsa public/private keypairs remove the need to enter
passwords. Then the copied tar.gz's can be copied from one remote
machine to all other WO servers in the cluster and inflated and
permissions can be set.
Tim, I am sure there are other ways too to skin the cat.
Yeah, for sure. I am pretty manually doing exactly what you
described sans clusters. I really want to look into launchd watch
paths on both the dev machine and deployment server. With the
proper keypairs it seems that the rest could be accomplished
automatically by hitting particular directory targets.
Thanks for your input!!
Tim
HTH, Kieran
On Jun 24, 2009, at 9:59 PM, Tim Worman wrote:
All:
context: I've been wanting to start some threads on simple best
practices and maybe get involved in helping with the wiki. From
my own work, this seemed as good a place to start as any.
--------------
I have a project that is pretty recently moved to Wonder. From
searching list posting and blogs I have seen mentions of
different configurations of Properties files that Wonder will
discover and use for database connection stuff, etc. Some of them
I hadn't seen mention of elsewhere.
I've recently started using Properties.<username> for doing dev
work and keeping passwords in there (and away from my code
repository). However, I've also recently seen whisper of a
Properties.dev.
Two things I'd like to see:
1. a full concise list of what all the possible Properties files
(requiring Wonder or not) and also how the more experienced among
us leverage them. If it turns out there are some that don't have
great documentation I'll volunteer to update the wiki!!
2. It still seems to me that another Properties file must be
inserted at deployment for different db passwords, etc. How do
the veterans among handle this? I've seen some deployment scripts
around but haven't dug into that stuff yet. I still build very
locally and deploy very manually (scp). :-)
Tim
UCLA GSE&IS
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden