JBOSS 6.3 Access log auto deletion - jboss

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>

Related

Jboss 7.1 logging filter in standalone.xml

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))"/>

Perform hourly logrotate on JBoss EAP 7 access log

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>

JBoss PeriodicSizeRotatingFileHandler duplicates current log file until disk runs out of space

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.

JBoss EAP 6.2 and Log4j2 stops writing logs after some time

I am using Log4j2 (RollingFile with routes) in my web application to log application specific logs in a few separate log files. The log4j2.xml file is bundled with in the WAR file.
Log files are generated and logs are generating fine to start with. After some time, it stops writing logs to the existing file and fails creating new folders/files too.
On restart everything resumes working and that is for some time only.
Tried monitoring, couldn't figure out any specific pattern or steps to simulate it.
<Configuration status="error" name="logger">
<Properties>
<Property name="logpath">path_to_log_file</Property>
</Properties>
<Appenders>
<Routing name="RoutingUserLogFile">
<Routes pattern="$${ctx:user}/">
<Route>
<RollingFile name="UserLogFile" fileName="${logpath}/${ctx:user}/MyLogFile.log" filePattern="${logpath}/${ctx:user}/%d{dd-MM-yyyy}-MyLogFile-%i.log.gz">
<PatternLayout>
<Pattern>%d %p %-40C{1.} %m%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true" />
<SizeBasedTriggeringPolicy size="4 MB" />
</Policies>
</RollingFile>
</Route>
</Routes>
</Routing>
</Appenders>
<Loggers>
<Root>
<level value="debug" />
<AppenderRef ref="RoutingUserLogFile" level="debug" />
</Root>
</Loggers>
</Configuration>

How do I delete old JBoss logs?

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