On Sep 12, 2007, at 9:11 PM, EJLeVin1 wrote:
Ok, so first off I want to apologize if this is kind of a newbie
question,
but we are making the migration from Tomcat to Geronimo, and I am
having a
hard time moving some of our application's logging. We have written a
custom log4j appender that utilizes both our custom jar, and 3x 3rd
party
jars. My original intent was to just add these three jars to
GERONIMO_HOME/lib and then configure the
GERONIMO_HOME/var/logs/server-log4j.properties file to make use of
this
appender with a filter to our namespace; however, this failed with
getting a
class not found error.
Hi Eric,
Good question... I may be proven wrong, but I don't know of a really
clean way to provide the function you're after... I have some options
that should get you running. However, would be helpful if you created
a Jira that suggests we make this easier/cleaner...
FYI, unlike Tomcat, mere presence of a jar in the lib/ directory will
not cause the jar to be added to the CLASSPATH of a Geronimo server.
Instead, META-INF/MANIFEST.MF in bin/server.jar is controlling the
CLASSPATH.
So, one straight-forward, but pretty dirty way of solving your
problem is to hack the MANIFEST.MF in server.jar.
Slightly better (?) is to set CLASSPATH via environment variable or -
cp command option. I think this means that you can't use 'java -jar
server.jar' (which is also used by geronimo.sh when starting
geronimo). So you'd have to do invoke java directly or update
geronimo.sh to do something like:
java -cp my-custom-logger.jar:bin/server.jar -javaagent:bin/jpa.jar -
Djava.endorsed.dirs=lib/endorsed
org.apache.geronimo.cli.daemon.DaemonCLI
That's totally untested...
You can always load and configure your logger on a per application
basis, but it sounds like you want this to be server wide... I guess
you could create a module which contains your custom appender, but
again that's not server wide...
I also tried adding these to the repository and it
didn't seem to work either. I am not sure whether this is the
correct route
to take (as in digging further into the GBean -- it would seem nice
to be
able to add our appender functionality by loading/unloading a GBean
within
Geronimo), but seemed to be the easiest. I was wondering if anyone
could
give an example of / knew how to do either of the following methods:
1) Adding the 3rd party jars to the j2ee-server module so that the
custom
appender can be resolved when loading log4j
Right. IMO, that's the way you want to solve this, but I don't know
how. Unless you build the server from source (which is another option).
2) Getting a handle on the running log4j instance (I think the
beans name is
"ServerLog"), and being able to add the appender/classes to the
configuration by means of a GBean.
Thanks anyone for your help, as I have been looking at this now for
quite
some time, and can't seem to find an answer anywhere.
--kevan