Logs

The default location of logs is /var/log/memgraph/memgraph.log but it can be changed using the --log-file configuration flag.

Memgraph tracks logs at various levels: TRACE, DEBUG, INFO, WARNING, ERROR, CRITICAL. By default, it is using the WARNING level, but you can change the level using the --log-level configuration file or during runtime using the SET DATABASE SETTING "log.level" TO "WARNING";

The configuration set during runtime will be applied only for that session.

You can check the log level by running SHOW DATABASE SETTING "log.level"; query.

If you are using Memgraph Lab, you can access the Logs from the interface if the port 7444 was exposed when running the instance.

Access logs

If you installed Memgraph with Linux, logs can be found in the /var/log/memgraph directory.

If you installed Memgraph using Docker:

Find container ID

Open a new terminal and find the CONTAINER ID of the Memgraph Docker container:

docker ps

Enter the container

Run the following command:

docker exec -it <CONTAINER ID> bash

Be sure to replace the <CONTAINER ID> parameter.

List the /var/log/memgraph directory

Position yourself in the /var/log/memgraph directory.

ls /var/log/memgraph

List the content of the log

To list the content of the log, use the cat /var/log/memgraph/<memgraph_date>.log command.

For example, if the ls command returned memgraph_2022-03-04.log you would list the contents using the following command:

cat /var/log/memgraph/memgraph_2022-03-04.log

Filtering unnecessary log messages

When you inspect Memgraph's log files, you might find too many details that make it hard to spot the important messages. To make analyzing the logs easier, you can use a tool such as grep to remove the messages you don't need. For instance,

if you want to ignore messages about internal Memgraph Lab work or too much information on storage, indexes, rules, and triggers, you can use this grep command:

grep -v -E "SHOW STORAGE INFO|APP_INTERNAL_EXEC_VAR|SHOW INDEX INFO|SHOW CONSTRAINT INFO|SHOW TRIGGERS" /var/log/memgraph/memgraph_2022-03-04.log

This command excludes log lines containing SHOW STORAGE INFO, any occurrences of APP_INTERNAL_EXEC_VAR, SHOW INDEX INFO, SHOW CONSTRAINT INFO, and SHOW TRIGGERS, making it easier to focus on the messages that are most relevant to your monitoring and troubleshooting efforts.

Note: Replace /var/log/memgraph/memgraph_2022-03-04.log with the actual path to your log file.

Save logs locally

If you want to save the log to your computer, exit the container with CTRL+D or exit, place yourself in a directory where you want to save the copy and run the following command:

docker cp  <CONTAINER ID>:/var/log/memgraph/<memgraph_date>.log <memgraph_date>.log

For example, the following command will make a copy of the memgraph_2022-03-04.log file on the user's desktop:

C:\Users\Vlasta\Desktop>docker cp bb3de2634afe:/var/log/memgraph/memgraph_2022-03-04.log memgraph_2022-03-04.log