I'm using JBoss 7.1.3 on Mac 10.9.1. This is a development machine. How do I delete old server logs that appear under the
$JBOSS_HOME/standalone/log
directory? Ideally, I'd like logs older than 4 days to be deleted from my system, freeing up disk space.
I am not sure whether you can auto delete files based on time lines of 4 days, the
<periodic-rotating-file-handler>
does not have the provision to do so.
However since your requirement is to free the disk space you can achieve that by using your config file (standalone or domain.xml).
By default the config file logging setting comes with periodic-rotating-file setting which looks like:
<periodic-rotating-file-handler name="FILE" autoflush="true">
<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>
Please change it to size-rotating-file-handler and define the log size(rotate-size) that you would want to maintain and the number of files(max-backup-index) by doing this you have fixed the size of your log directory and always rotate within the given size allocations.
<size-rotating-file-handler name="FILE" autoflush="true" >
<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"/>
<append value="true"/>
<rotate-size value="10000K"/>
<max-backup-index value="3"/>
</size-rotating-file-handler>
Note that suffix does not work with <size-rotating-file-handler>
For more info
Related
I am looking for a solution in JBOSS EAP 6.3 for the automatic deletion of access logs. I have added the below configuration to get the access logs printed in a different file but it doesn't have any parameter to delete the files after a specific interval.
<access-log pattern="%h %l %u %t %r %s %b %S %T" prefix="access_log_" rotate="true">
<directory path="." />
</access-log>
In standalone.xml , you can have log handler configuration based on the size.
<size-rotating-file-handler name="FILE" autoflush="true">
<formatter>
<named-formatter name="PATTERN"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="server.log"/>
<rotate-size value="1M"/>
<max-backup-index value="1"/>
<append value="true"/>
</size-rotating-file-handler>
In Jboss 7.1 how to configure standalone.xml to log only INFO level
<periodic-rotating-file-handler name="FILE">
<level name="INFO"/>
<formatter>
<pattern-formatter pattern="%z{utc}%d{MM/dd/yyyy HH:mm:ss,SSS} %-5p [%c] %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>
By default root loggers are configured to print INFO level logs. If you have to change log level for any other logger category or log handlers. Just add below tag to that particular category or handler.
<level name="INFO"/>
If you have log only INFO level logs, you will have t0 implement filter something like
<filter-spec value="(levels(INFO))"/>
By default, JBoss EAP 7 rotates its access log daily.
I needed to set this to like, HOURLY.
Reason:
We have a script that automatically downloads the rotated access log file.
But doing this ^ would greatly increase CPU usage (because the access log at the end of the day is VERY large, and our system's performance is unfortunately reduced while downloading it)
What I know is that, in the standalone.xml, I've tried adding the one below to make the JBoss server log to rotate every hour.
<suffix value=".yyyy-MM-dd-HH"/>
But this method does not apply to access log (because its settings is weirdly placed in a different part of the standalone.xml)
I've tried experimenting with the access-log tags to have any of the following. But it just throws an error.
<access-log suffix=".yyyy-MM-dd-HH" ...
<access-log rotate="hourly" ...
...and i can't seem to find a VERY detailed guide about standalone.xml of JBoss EAP 7. I'm thinking that I should use a tag value for the access-log part.
Please help. Does anyone know of a way to do this? :(
System specs
Oracle Linux 6.9
JBoss EAP 7
Thanks and best regards.
Try following
<subsystem xmlns="urn:jboss:domain:logging:3.0">
...(snip)...
<!-- size-based log rotation -->
<size-rotating-file-handler name="access-log" autoflush="true">
<formatter>
<named-formatter name="access-log-formatter"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="access.log"/>
<rotate-size value="10m"/>
<max-backup-index value="10"/>
<append value="true"/>
</size-rotating-file-handler>
<! -- or custom interval (hourly) log rotation
<periodic-rotating-file-handler name="access-log-custom" autoflush="true">
<formatter>
<named-formatter name="access-log-formatter"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="access.log"/>
<suffix value=".yyyy-MM-dd-HH"/>
<append value="true"/>
</periodic-rotating-file-handler>
--->
...(snip)...
<logger category="io.undertow.accesslog" use-parent-handlers="false">
<handlers>
<handler name="access-log"/>
</handlers>
</logger>
...(snip)...
<formatter name="access-log-formatter">
<pattern-formatter pattern="%s%n"/>
</formatter>
</subsystem>
...(snip)...
<subsystem xmlns="urn:jboss:domain:undertow:3.1" statistics-enabled="true">
...(snip)...
<server name="default-server">
<http-listener name="default" socket-binding="http" redirect-socket="https" record-request-start-time="true"/>
<host name="default-host" alias="localhost">
...(snip)...
<access-log use-server-log="true" pattern="%h %l %u %t "%r" %s %b "%{i,Referer}" "%{i,User-Agent}" "%{i,COOKIE}" "%{o,SET-COOKIE}" %S "%I" %T"/>
...(snip)...
</host>
</server>
...(snip)...
</subsystem>
Sometimes we have the issue that the log rotate will duplicate the current log file until the disk runs out of space. We don't see any issues in the log files and we were wondering how this could happen as we are using the standard PeriodicSizeRotatingFileHandler from JBoss.
Server version: Windows Web Server 2008 R2
JBoss EAP version: 6.4.17
Please find below a part of our standalone.xml
<subsystem xmlns="urn:jboss:domain:logging:1.5">
<custom-handler name="FILE" class="org.jboss.logmanager.handlers.PeriodicSizeRotatingFileHandler" module="org.jboss.logmanager">
<level name="INFO"/>
<formatter>
<pattern-formatter pattern="%d{yyyyMMdd HH:mm:ss,SSS} %-5p [%c{1}] (%t) %s%E [MDC:ibizaId=%X{ibizaId}]%n"/>
</formatter>
<properties>
<property name="append" value="true"/>
<property name="rotateSize" value="200000000"/>
<property name="maxBackupIndex" value="1000"/>
<property name="suffix" value=".yyyy-MM-dd"/>
<property name="fileName" value="${jboss.server.log.dir}/server.log"/>
</properties>
</custom-handler>
</subsystem>
Unfortunately I couldn't find anything related to this issue on Google.
Hi We are using JBoss EAP 6.1.0 for our project, i am trying to find a way to configure sending emails for loglevel ERROR in standalone.xml but i didn't fine any documentation which provides some example i added the below configuration to my standalone.xml but i am getting parsing exception after that.
Here is my code:
<subsystem xmlns="urn:jboss:domain:logging:1.2">
<console-handler name="CONSOLE">
[Some Code Here]
</console-handler>
<custom-handler name="EMAIL" class="org.apache.log4j.net.SMTPAppender" module="org.apache.log4j">
<level name="ERROR"/>
<formatter>
<pattern-formatter pattern="%d %-5p [%c] %m%n"/>
</formatter>
<properties>
<property name="BufferSize" value="10"/
<property name="SMTPHost" value="localhost"/>
<property name="From" value="sviswanadha#corelogic.com"/>
<property name="To" value="sviswanadha#corelogic.com"/>
<property name="Subject" value="SWS Error Log"/>
</properties>
</custom-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>
<logger category="com.arjuna">
<level name="WARN"/>
</logger>
<logger category="org.apache.tomcat.util.modeler">
<level name="WARN"/>
</logger>
<logger category="sun.rmi">
<level name="WARN"/>
</logger>
<logger category="jacorb">
<level name="WARN"/>
</logger>
<logger category="jacorb.config">
<level name="ERROR"/>
</logger>
<root-logger>
<level name="INFO"/>
<handlers>
<handler name="CONSOLE"/>
<handler name="FILE"/>
<handler name="EMAIL"/>
</handlers>
</root-logger>
</subsystem>
Exception I am getting:
JBAS014789: Unexpected element '{urn:jboss:domain:logging:1.2}handler-ref' encountered
Help in providing suggestions/solution is much appreciated.
JBoss AS 7 no longer uses log4j. It uses jboss-logging which seems to delegate to ava.util.logging.Handlers see also https://github.com/jboss-logging/jboss-logmanager/tree/master/src/main/java/org/jboss/logmanager/handlers.
Maybe you already have the answer, but your xml is not valid.
<properties>
<property name="BufferSize" value="10"/ <--- missing character
<property name="SMTPHost" value="localhost"/>
<property name="From" value="sviswanadha#corelogic.com"/>
<property name="To" value="sviswanadha#corelogic.com"/>
<property name="Subject" value="SWS Error Log"/>
</properties>