I'm trying to tell my jboss to write an access log with all information I need and use a daily log rotation. So far this is not an issue. The ultimate goal is to send all access log entries to an elk stack using logstash forwarder. Also not that big a deal. The problem I'm having now is to define the access logs names.
JBoss offers log rotation out of the box but adds a timestamp to each logfile so todays file also has a timestamp suffix.
What I want to achive is the same behavior as tomcat or as jbosses server.log. Meaning todays file should just be named access.log and only have a suffix appended when todays file becomes yesterdays file and hence is rotated into inactve state.
my jboss config looks like this:
<subsystem xmlns="urn:jboss:domain:logging:1.3">
<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>
<periodic-rotating-file-handler name="ACCESS" 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="access.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="org.jboss.as.config">
<level name="DEBUG"/>
</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="FILE"/>
<handler name="ACCESS"/>
</handlers>
</root-logger>
</subsystem>
And here is my access-log config with log rotation enabled (has above mentioned timestamp behavior). When I set rotate="false" I get an access.log which it's not ratated.
<subsystem xmlns="urn:jboss:domain:web:1.5" default-virtual-server="default-host" native="false">
<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
<virtual-server name="default-host" enable-welcome-root="true">
<alias name="localhost"/>
<alias name="example.com"/>
<access-log pattern=""%{HOST}i" - %h %t "%m" "%U" - "%q" - "%H" - %s %B "%{User-Agent}i" %T %D "%p"" prefix="access.log" rotate="true">
<directory path="."/>
</access-log>
</virtual-server>
</subsystem>
Right now I see two ways to send the logfiles to my elk stack. First is writing into an access.log with no timestamp and add timestamp on rotation so the logstash forwarder can always read access.log. Second is set up the forwarders config to always check the newest access.log file. This way the timestamped filename wouldn't be an issue. But I don't know if thats possible.
I'd be grateful for any advice. Thanks and regards. Sebastian