Configuring Logging
Logging in Baleen, as well as a number of other settings, is configured in the Baleen configuration file. This is the file you pass to Baleen from the command line, for example: java -jar baleen-2.x.0.jar config.yml
In the above example, config.yml
is the name of the configuration file and this is the name we will refer to it by during this guide. Calling it config.yml
isn't required though, and you can call it whatever you want so long as that's the file you pass to Baleen when you start it up.
The configuration file is a YAML file, and uses YAML markup to configure Baleen. If you're not familiar with YAML markup, you should look at some online tutorials as we will not cover the syntax in this guide.
The configuration file is made up of a number of sections, and the logging section is indicated by the logging
property. We then define a list of loggers using the loggers
property. For example, here's a simple config.yml
to log things to the console.
logging: loggers: - name: console
The logger name is indicated with the name
property, as shown above. The name console
is a special case to log to the standard console, if a different name is provided it will log to file (by default a file with the same name as the name
value you provided).
Multiple loggers can be specified by adding further list items to the loggers
key. If specifying a file name, the log file will be written to the current running directory.
The name
property isn't the only option you can specify, and there are a number of properties you can specify to control things such as the file name, the maximum file size, the logging levels to log, the packages to log, and more. These are all documented in the JavaDoc (see uk.gov.dstl.baleen.core.logging.BaleenLogging
to get started), so rather than go through them in detail here we will just provide some common 'recipes' from which you can start configuring your logging to suit your needs.
logging: loggers: - name: errors.log minLevel: WARN
logging: loggers: - name: warnings.log minLevel: WARN maxLevel: WARN - name: errors.log minLevel: ERROR
logging: loggers: - name: ignoreJetty file: baleen.log excludeLoggers: - org.eclipse.jetty
logging: loggers: - name: baleen.log size: 32
logging: loggers: - name: baleen.log daily: true history: 7