|
| 1 | +--- |
| 2 | +title: Configuring logging settings |
| 3 | +parent: Admin manual |
| 4 | +--- |
| 5 | + |
| 6 | +Reconmap API can be configured to log application messages to multiple destinations including local files or remote sys log servers. |
| 7 | + |
| 8 | +### Logging to local files |
| 9 | + |
| 10 | +Edit the `config.json` to show the following content at the top level: |
| 11 | + |
| 12 | +```json |
| 13 | +{ |
| 14 | + ... |
| 15 | + "logging": { |
| 16 | + "file": { |
| 17 | + "enabled": true, |
| 18 | + "level": "debug", |
| 19 | + "path": "/var/www/webapp/logs/application.log" |
| 20 | + } |
| 21 | + }, |
| 22 | + ... |
| 23 | +} |
| 24 | +``` |
| 25 | + |
| 26 | +### Logging to Graylog using GELF |
| 27 | + |
| 28 | +First make sure to spin up a [Graylog](https://www.graylog.org/) somewhere in your system. You can use the following docker compose file to start one with all its dependencies. |
| 29 | + |
| 30 | +```yaml |
| 31 | +version: "3.8" |
| 32 | + |
| 33 | +services: |
| 34 | + elasticsearch: |
| 35 | + image: "docker.elastic.co/elasticsearch/elasticsearch:7.12.1" |
| 36 | + environment: |
| 37 | + - node.name=elasticsearch |
| 38 | + - cluster.name=docker-cluster |
| 39 | + - bootstrap.memory_lock=true |
| 40 | + - discovery.type=single-node |
| 41 | + - xpack.security.enabled=false |
| 42 | + - "ES_JAVA_OPTS=-Xms512m -Xmx512m" |
| 43 | + ulimits: |
| 44 | + memlock: |
| 45 | + soft: -1 |
| 46 | + hard: -1 |
| 47 | + volumes: |
| 48 | + - esdata:/usr/share/elasticsearch/data |
| 49 | + ports: |
| 50 | + - 9200:9200 |
| 51 | + mongodb: |
| 52 | + image: "mongo:4.2" |
| 53 | + restart: always |
| 54 | + |
| 55 | + graylog: |
| 56 | + image: "graylog/graylog:4.3.2" |
| 57 | + depends_on: |
| 58 | + - elasticsearch |
| 59 | + - mongodb |
| 60 | + entrypoint: "/usr/bin/tini -- wait-for-it elasticsearch:9200 -- /docker-entrypoint.sh" |
| 61 | + environment: |
| 62 | + GRAYLOG_PASSWORD_SECRET: somepasswordpepper |
| 63 | + # to generate a password hash, type: echo -n admin | shasum -a 256 |
| 64 | + GRAYLOG_ROOT_PASSWORD_SHA2: 8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918 |
| 65 | + GRAYLOG_HTTP_BIND_ADDRESS: "0.0.0.0:9001" |
| 66 | + GRAYLOG_HTTP_EXTERNAL_URI: "http://localhost:9001/" |
| 67 | + GRAYLOG_ELASTICSEARCH_HOSTS: "http://elasticsearch:9200" |
| 68 | + GRAYLOG_MONGODB_URI: "mongodb://mongodb:27017/graylog" |
| 69 | + ports: |
| 70 | + - "5044:5044/tcp" # Beats |
| 71 | + - "5140:5140/udp" # Syslog |
| 72 | + - "5140:5140/tcp" # Syslog |
| 73 | + - "5555:5555/tcp" # RAW TCP |
| 74 | + - "5555:5555/udp" # RAW TCP |
| 75 | + - "9001:9001/tcp" # Server API |
| 76 | + - "12201:12201/tcp" # GELF TCP |
| 77 | + - "12201:12201/udp" # GELF UDP |
| 78 | + - "13301:13301/tcp" # Forwarder data |
| 79 | + - "13302:13302/tcp" # Forwarder config |
| 80 | +volumes: |
| 81 | + esdata: |
| 82 | +``` |
| 83 | +
|
| 84 | +Ensure to edit `config.json` file to enable the gelf log handler and point to the hostname and IP of your graylog server. |
| 85 | + |
| 86 | +```json |
| 87 | +{ |
| 88 | + ... |
| 89 | + "logging": { |
| 90 | + "gelf": { |
| 91 | + "enabled": true, |
| 92 | + "level": "debug", |
| 93 | + "serverName": "api-graylog-1", |
| 94 | + "serverPort": 12201 |
| 95 | + } |
| 96 | + }, |
| 97 | + ... |
| 98 | +} |
| 99 | +``` |
| 100 | + |
| 101 | +Now you can view all your application logs from the convenience of your browser at [http://localhost:9001](http://localhost:9001) |
| 102 | + |
| 103 | + |
0 commit comments