-
1. Re: How to auto-deploy log4j configuration changes
sfcoy Jun 27, 2013 8:30 PM (in response to atulkc)1 of 1 people found this helpfulHi there,
You can control AS7.x+ logging at runtime using the CLI, as described in https://docs.jboss.org/author/display/AS71/CLI+Recipes#CLIRecipes-Addalogcategory.
-
2. Re: How to auto-deploy log4j configuration changes
atulkc Jun 27, 2013 9:36 PM (in response to sfcoy)I tried changing the logging configuration using CLI as you indicated but looks like it works only for the loggers configured through logging subsystem in standalone-full.xml. However, this approach doesn't seem to work for the categories configured by jboss-log4j.xml in META-INF of application ear. I used jconsole CLI plugin to check if I can build CLI for jboss-log4j.xml under application deployment but couldn't find any way to do it.
-
3. Re: How to auto-deploy log4j configuration changes
sfcoy Jun 27, 2013 9:51 PM (in response to atulkc)I was not actually aware that there was any support for jboss-log4j.xml in the way that you describe in earlier versions of JBossAS.
In any event, I don't believe that that capability exists anymore.
You can include application specific logging configuration in the logging subsystem. I think this is actually preferable because the server configuration gets propogated to the various nodes in a cluster.
It looks like you're deploying an exploded ear just so that you can get at the logging configuration. This is no longer necessary if you push the config into the server itself.
In fact, you write a CLI script that configures logging, etc and deploys your application as well.
-
4. Re: How to auto-deploy log4j configuration changes
wdfink Jun 28, 2013 2:10 AM (in response to atulkc)As far as I know if you add such logging configuration to the application you need to re-deploy the application, this is possible with the CLI if you use exploded deployment.
I not recommend to use autodeploy (disabled by default) for exploded deployments as each filechange will force a redeploy.
-
5. Re: How to auto-deploy log4j configuration changes
sfcoy Jun 28, 2013 4:31 AM (in response to wdfink)Does this mean that AS7.x supports the use of jboss-log4j.xml?
With or without application provided jars?
In AS7.x (and presumably other JEE6+ compliant containers) the content of an app.ear/META-INF directory is inaccessible from the application classloader.
-
6. Re: How to auto-deploy log4j configuration changes
jamezp Jun 28, 2013 1:39 PM (in response to sfcoy)Yes you can use a jboss-log4j.xml within a deployment to configure log4j. This works in EAP 6.1, WildFly and the AS 7.2.0.Final tag if you build off it. I'm not sure the differences in log4j.xml and jboss-log4j.xml if there are any. Essentially what it does is just configure it as if it was a log4j.xml file.
--
James R. Perkins
-
7. Re: How to auto-deploy log4j configuration changes
jamezp Jun 28, 2013 1:42 PM (in response to atulkc)1 of 1 people found this helpfulThere is no built-in support for runtime changes to log4j configuration files. You either have to use something like the org.apache.log4j.xml.DOMConfigurator.configureAndWatch() in internal code or use the logging subsystem. While a bit on the buggy side you can use log4j appenders as custom-handlers in the logging subsystem which would allow for runtime changes and you could leave the jboss-log4j.xml file out of your deployment.
--
James R. Perkins
-
8. Re: How to auto-deploy log4j configuration changes
atulkc Jun 28, 2013 5:00 PM (in response to jamezp)Thanks everyone for your comments. Since changing logging level at runtime without having to redeploy application is one of very important requirements from development team I will have to switch to using jboss logging subsystem. We used org.apache.log4j.rolling.RollingFileAppender to compress the rolled over files. Is there any way we can achieve compression of the rolled over log files using perdiocFileHandler?
I tried configuring org.apache.log4j.rolling.RollingFileAppender as custom-handler in jboss logging subsystem as follows:
<custom-handler name="TEST" class="org.apache.log4j.rolling.RollingFileAppender" module="org.apache.log4j-extras">
<properties>
<property name="rollingPolicy" value="org.apache.log4j.rolling.TimeBasedRollingPolicy"/>
<property name="File" value="${dcm.home.dir}/logs/server/test.log"/>
</properties>
</custom-handler>
But jboss fails to start complaining that parameter type is not correct. Looks like I will have to write a wrapper Handler class and deploy it as a module and use it in logging subystem as custom handler to achieve the desired behavior. If there is any other easier way to do it then please let me know.
Thanks.
-
9. Re: How to auto-deploy log4j configuration changes
jamezp Jun 28, 2013 5:13 PM (in response to atulkc)Ah, it probably can't set the rollingPolicy since it requires an unknown type. The periodic-rotating-file-handler will not compress files. Really though you could just us a cron job to do that if needed. The other option would be, as you suggest, just writing a custom handler.
--
James R. Perkins