/subsystem=logging/logger=com.your.category:add
/subsystem=logging/logger=com.your.category:add
To change a handlers log level:
/subsystem=logging/console-handler=CONSOLE:write-attribute(name=level,value=DEBUG)
Changing the level on a log category is the same:
/subsystem=logging/logger=com.your.category:write-attribute(name=level,value=ALL)
Create a file handler. There are 3 different types of file handlers to choose from; file-handler, periodic-rotating-file-handler and size-rotating-file-handler. In this example we'll just use a simple file-handler.
/subsystem=logging/file-handler=fh:add(level=INFO, file={"relative-to"=>"jboss.server.log.dir", "path"=>"fh.log"}, append=false, autoflush=true)
Now create the log category.
/subsystem=logging/logger=org.your.company:add(use-parent-handlers=false,handlers=\["fh"\])
First note that if you choose to use a log4j configuration file, you will no longer be able to change the log4j logging configuration at runtime.
Create a jboss-deployment-structure.xml with the following content and place it in the META-INF/ directory if you are deploying an EAR and also on META-INF/ or WEB-INF/ directory if you are deploying a WAR.
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"> <!-- for top deployment, e.g. ear --> <deployment> <!-- Exclusions allow you to prevent the server from automatically adding some dependencies --> <exclusions> <module name="org.apache.log4j" /> </exclusions> </deployment> <!-- for sub deployment, e.g. war. sub-deployment is required when ear contains one or more wars --> <sub-deployment name="AAA.war"> <exclusions> <module name="org.apache.log4j" /> </exclusions> </sub-deployment> <sub-deployment name="BBB.war"> <exclusions> <module name="org.apache.log4j" /> </exclusions> </sub-deployment> </jboss-deployment-structure>
Include the log4j.properties or log4j.xml file in the lib/ directory in your deployment.
Deploy your application.
<subsystem xmlns="urn:jboss:domain:logging:1.1"> ... <file-handler name="fh"> <level name="INFO"/> <file relative-to="jboss.server.log.dir" path="fh.log"/> <autoflush value="true"/> <append value="false"/> </file-handler> <logger category="com.your.company" use-parent-handlers="false"> <handlers> <handler name="fh"/> </handlers> </logger> ... </subsystem>