Basic Configuration
The software you downloaded comes with a sample configuration file named analytics.conf.example. You can remove the “.example” suffix and edit the file to your needs.
Config File Structure
See the sample configuration files for more details, here we just provide some basic information.
There is a number of sections in the file, each section is marked by its name put in the square brackets. Here are the sections:
- [license] — configures the license the software is used with. You can select between the free license for non-commercial usage or the commercial license if you use the software for the commercial website;
- [database] — here you setup the database parameters of the software. Log Analytics currently works with SQLite databases only, more options to come later. See the example configuration file for the database path options.
- [server] — defines the host name and port where the application will be listening for web browser requests, providing a web interface for seeing the website statistics;
- [cache] — controls the reports caching parameters.
Config File Location
Log Analytics looks for its configuration file in two folders:
- the current folder where the application is executed from;
- the current user home folder ($HOME on Unix systems, %PROFILE% on Windows).
The software checks these folders in the order provided above and looks for a file named .analytics.conf or analytics.conf there. If the file is found — it is parsed for the configuration options and no further search is made. If the file has errors – the software stops.
Specifying the Config Location
You can put the config file somewhere else and tell Log Analytics to use it instead using the -c or –config command line parameter:
./analytics -c ~/.config/analytics/config
analytics.exe --config d:\analytics\analytics.conf
Configuration Using Environment Variables
This is convenient if you are going to use Log Analytics in Docker or for some reasons don’t want to use the config file mentioned above.
Here is the list of environment variables the software reads:
- DATABASE_URL — same as the url parameter of [database];
- DATABASE_ROWS_FETCHED_AT_ONCE — same as rowsFetchedAtOnce there;
- WEB_HOST — use instead host of the [server] section;
- WEB_PORT — use instead of the port parameter there;
- CACHE_TIMEOUT — same as timeout in [cache];
- LICENSE_COMMERCIAL — same as commercial in [license].
Here’s how you can configure host and port using the environment variables:
WEB_HOST=localhost WEB_PORT=3000 ./analytics server
Configuration Using .env File
You can put the options above in a file named .env and put it right next to the Log Analytics executable. It will work exactly the same as if you set the environment variables directly.
Here is a sample .env file:
WEB_HOST=localhost
WEB_PORT=3000
LICENSE_COMMERCIAL=true
Once the configuration is complete, proceed to the Properties Creation Tutorial.