-
1. Re: Jboss AS 7 logging level change need restart?
bwallis42 May 7, 2012 8:27 AM (in response to sarula)If you make the change via the web admin interface (http://localhost:9990/) then a restart is not required, you could also do this via the cli (bin/jboss-cli.sh) but I'm not sure of the actual command to do it.
The manual at https://docs.jboss.org/author/display/AS7/Admin+Guide#AdminGuide-ConfigurationFiles says
{quote}
The XML configuration files act as a central, authoritative source of configuration. Any configuration changes made via the web interface or the CLI are persisted back to the XML configuration files. If a domain or standalone server is offline, the XML configuration files can be hand edited as well, and any changes will be picked up when the domain or standalone server is next started. However, users are encouraged to use the web interface or the CLI in preference to making offline edits to the configuration files. External changes made to the configuration files while processes are running will not be detected, and may be overwritten.
{quote}
-
2. Re: Jboss AS 7 logging level change need restart?
bwallis42 May 7, 2012 7:15 PM (in response to bwallis42)I have been using the admin web interface for this but wondered how to add and remove loggers from the cli so I had a play.
The following shows how I could add and remove a logger for org.jboss.as with a level of TRACE
{noformat}
bwallis@master:~/JBoss/jboss-as-7.1.2.Final-SNAPSHOT> bin/jboss-cli.sh
You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
[disconnected /] connect 172.16.95.131
[domain@172.16.95.131:9999 /] ls /profile=full-ha/subsystem=logging/logger
com.arjuna jacorb jacorb.config org.apache.catalina.authenticator org.apache.tomcat.util.modeler org.jboss.as.clustering.infinispan
org.jboss.as.clustering.web.infinispan org.jboss.as.clustering.web.sso sun.rmi
[domain@172.16.95.131:9999 /] /profile=full-ha/subsystem=logging/logger=org.jboss.as:add(level=TRACE)
{
"outcome" => "success",
"result" => undefined,
"server-groups" => {"other-server-group" => {"host" => {"master" => {"server-three" => {"response" => {"outcome" => "success"}}}}}}
}
[domain@172.16.95.131:9999 /] /profile=full-ha/subsystem=logging/logger=org.jboss.as:read-resource
{
"outcome" => "success",
"result" => {
"filter" => undefined,
"handlers" => undefined,
"level" => "TRACE",
"use-parent-handlers" => true
}
}
[domain@172.16.95.131:9999 /] ls /profile=full-ha/subsystem=logging/logger
com.arjuna jacorb jacorb.config org.apache.catalina.authenticator org.apache.tomcat.util.modeler org.jboss.as
org.jboss.as.clustering.infinispan org.jboss.as.clustering.web.infinispan org.jboss.as.clustering.web.sso sun.rmi
[domain@172.16.95.131:9999 /] /profile=full-ha/subsystem=logging/logger=org.jboss.as:remove
{
"outcome" => "success",
"result" => undefined,
"server-groups" => {"other-server-group" => {"host" => {"master" => {"server-three" => {"response" => {"outcome" => "success"}}}}}}
}
[domain@172.16.95.131:9999 /] ls /profile=full-ha/subsystem=logging/logger
com.arjuna jacorb jacorb.config org.apache.catalina.authenticator org.apache.tomcat.util.modeler org.jboss.as.clustering.infinispan
org.jboss.as.clustering.web.infinispan org.jboss.as.clustering.web.sso sun.rmi
{noformat}
The effect of the add and remove is immediate without out any server restart.
-
3. Re: Jboss AS 7 logging level change need restart?
sarula May 7, 2012 10:20 PM (in response to bwallis42)Many thanks for your reply.
I am on Windows and my app is migrating from jboss 4 to 7. Before migrate log4j was used for logging configuration and we used Appender element to change log level without restart.
So I am wandering if there are similar way to do in Jboss 7. Or I have to configure log4j in jboss 7 ?
Thanks
Sarula
-
4. Re: Jboss AS 7 logging level change need restart?
bwallis42 May 8, 2012 12:17 AM (in response to sarula)Hi Sarula,
No, no log4j configuration needed (or available). The equivilent is the handler configuration in the logging subsystem entry in either standalone.xml or domain.xml like so:
{code}
<subsystem xmlns="urn:jboss:domain:logging:1.1">
<console-handler name="CONSOLE">
<level name="TRACE"/>
<formatter>
<pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
</formatter>
</console-handler>
<periodic-rotating-file-handler name="FILE">
<formatter>
<pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="server.log"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</periodic-rotating-file-handler>
...
</subsystem>
{code}
You can edit this if the server is not running but to change it at runtime you just use either the admin web UI or the CLI.
ie: to set the console log level to TRACE using the CLI script (there is a version, jboss-cli.bat, for windows in the bin directory)
{code}
bwallis@master:~/JBoss/jboss-as-7.1.2.Final-SNAPSHOT> bin/jboss-cli.sh
[disconnected /] connect 172.16.95.131
[domain@172.16.95.131:9999 /] /profile=full-ha/subsystem=logging/console-handler=CONSOLE:write-attribute(name=level,value=TRACE)
{
"outcome" => "success",
"result" => undefined,
"server-groups" => {"other-server-group" => {"host" => {"master" => {"server-three" => {"response" => {"outcome" => "success"}}}}}}
}
{code}
and then check the value
{code}
domain@172.16.95.131:9999 /] /profile=full-ha/subsystem=logging/console-handler=CONSOLE:read-resource
{
"outcome" => "success",
"result" => {
"autoflush" => true,
"encoding" => undefined,
"filter" => undefined,
"formatter" => "%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n",
"level" => "TRACE",
"target" => "System.out"
}
}
{code}
or just use the admin web UI as shown in the attached image (click on the edit button to change the log level)
Both these methods will make the change and persist it to the standalone.xml or domain.xml files.
(Note that the CLI examples I've given are all for a server running in domain mode, in standalone mode I think the path is a little different, the "/profile=full-ha" part is missing).
-
AdminLogging.jpg 88.8 KB
-
-
5. Re: Jboss AS 7 logging level change need restart?
jamezp May 8, 2012 1:19 PM (in response to bwallis42)Correct about the standalone part for CLI.
Note the handler must be able to log debug messages as well as the logger, e.g. category, in order for debug messages to appear. For example, I'll show standalone examples, you want to see debug messages from your application you need to add a logger for your application.
/subsystem=logging/logger=com.example:add(level=TRACE)
By default the server.log is set to accept all levels so any logger created with a TRACE or DEBUG level will go in there. If you want to see TRACE messages on the console you need to change the consoles log level too.
/subsystem=logging/console-handler=CONSOLE:write-attribute(name=level,value=TRACE)
This works the same on all platforms BTW.
Changes to the XML while the server is running may very well get written over so it's highly suggested you don't make the changes when the server is running.
For more information see the How To's on changing the log levels. At some point some more how to's/ recipes will be added to the documentation.
On a side not too, as of 7.2.x deployments that contain a log4j or logging.properties configuration file will automatically be configured to work with that configuration when the application is deployed. The only caveat is that you cannot make changes to the deployments logging configuration via CLI, the web console or any other management operations.
--
James R. Perkins
-
6. Re: Jboss AS 7 logging level change need restart?
xerces8 Nov 11, 2013 8:32 AM (in response to bwallis42)Brian Wallis wrote:
If you make the change via the web admin interface (http://localhost:9990/) then a restart is not required, you could also do this via the cli (bin/jboss-cli.sh) but I'm not sure of the actual command to do it.
I used the web admin GUI to change the formatter pattern from "%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n" to "%d{dd.MM.yyyy HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n".
The change was visible in standalone.xml immediately, but the actual logs were still using the old format (I waited more than a minute).
Then I restarted jboss and the new format was used. Then I changed it back (again in admin GUI) and this time the change was applied to the logs without restarting
Any idea what is happening?
I use JBoss AS 7.1.1.
Regards,
David
PS: It seems whenever I change the formatter in the admin GUI, the logging reverts to the default format of "%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n", no matter what I enter. Only after restart, the entered format is used. A bug?
PPS: On the other hand, changing the log level in admin GUI works fine.
-
7. Re: Jboss AS 7 logging level change need restart?
ctomc Nov 11, 2013 8:40 AM (in response to xerces8)Did you try in any newer version of AS?
maybe 7.2 or WildFly8. there ware many many changes in logging subsystem since 7.1.1
--
Tomaž
-
8. Re: Jboss AS 7 logging level change need restart?
xerces8 Nov 13, 2013 11:33 AM (in response to ctomc)No, it is on production.
-
9. Re: Jboss AS 7 logging level change need restart?
jamezp Nov 13, 2013 12:48 PM (in response to xerces8)I couldn't get this to work either. Not sure what the issue is, but it's fixed in EAP 6.1 for sure I just tested. You could try running on EAP instead, JBoss Application Server Downloads - JBoss Community.
--
James R. Perkins -
10. Re: Jboss AS 7 logging level change need restart?
icemaker Jan 29, 2014 8:38 AM (in response to sarula)Could this be done through jmx ?
-
11. Re: Jboss AS 7 logging level change need restart?
bvnghiem1012 Feb 28, 2014 5:01 AM (in response to sarula)I also have the same question. I would like to change the log level from JMX. How can I do?
-
12. Re: Jboss AS 7 logging level change need restart?
wdfink Feb 28, 2014 11:32 AM (in response to bvnghiem1012)From AS7 the core is not longer based on MBeans.
The Configuration can be done via management interface (CLI console or programatic API) only
-
13. Re: Jboss AS 7 logging level change need restart?
xerces8 Jul 18, 2014 3:22 AM (in response to wdfink)It can also be done in the web console.