Skip to content

Logging

Allan Poindexter edited this page Feb 20, 2018 · 3 revisions

Logging for BAM makes use of three technologies: Log4j, AOP, and Splunk.

Log4j

Log4j's configuration file is log4j2-spring.xml and it can be found in the src/main/resources folder. Currently, Log4j uses two appenders -- RollingFile and Console -- that will output to a .log file and the IDE console respectively. Each appender displays events in a different format. The RollingFile appender will print events in a JSON format, which will be parsed automatically when read by Splunk. The Console appender exists to make the application output readable, but it's possible to change the color of the console output, if desired.

RollingFile Appender

The RollingFile appender does most of the work for keeping the application's log files. The appender will write to the log file until the current log reaches 10MB in size. When 10MB is reached, the current file is pushed aside, and a new log file is created for recording events. The appender is also set to create a new log every day, even if the previous log hasn't reached 10MB.

Rollover Strategy

There is also a nested DefaultRolloverStrategy within the RollingFile appender. This tag supplies the retention and deletion policies, and grants a limit on the amount of logs generated within a certain timeframe. Log4j will automatically create new log files up to 20 times within a one-day period (refer to the 10MB limit). The appender will also watch the log directory's file size, deleting the oldest log if the directory reaches over 2GB in size. Any logs older than 60 days old will be deleted automatically.

AOP

Events are recorded using Spring AOP, handled by the ServiceAndControllerLogger class under the logging package. Pointcut expressions are set to capture method calls from the controller and service methods. Each will record events to the log file in a JSON format. The current JSON format is taken from each beans' toString() method.

Splunk

Splunk is the log seraching and reporting application used to monitor, collect, and display the log directory. Events are logged as JSON, and Splunk will automatically parse events into a readable format. It will also extract keys from the JSON message, and the user can search for this automatically.

Splunk is currently installed on the same EC2 as BAM, and is accessible on port 8000 on the EC2's live url.

Clone this wiki locally