Logs are probably one of the most basic forms of troubleshooting and diagnostic measures. Depending on the application and logging level, logs can provide detailed information about every application’s action.
In Apache Cassandra, logging functionality is provided by the Simple Logging Façade for Java, with a backend provided by the logback.
Apache Cassandra provides three log files. These files include:
- log – This file stores various activities in the Cassandra cluster such as uncaught exceptions, keyspace/table CRUD operations, background processes, and more. This file acts as the default log file for a specific cluster.
- log – The debug.log file holds additional information about the cluster. This contains the info primarily likely to be useful when troubleshooting problems in your cluster. You’ll find the log information such as memtable flushes, commit logs, etc.
- log – This contains the Java GC log information. This file is highly verbose with information such as application pauses, JVM operations, latency, etc.
Log files in the Apache Cassandra cluster are stored in the default logging directory. The default path is located at /var/log/cassandra.
For example, the following screenshot shows the log files in a local Cassandra cluster.
NOTE: By default, Apache Cassandra rolls the system.log and debug.log to compressed zip files after the size exceeds 20MB.
View Current Log Level
To view the current logging information, you can use the nodetool getlogginglevels command as shown:
The command should return the log name and the currently set log level. An example output is shown in the following:
ROOT INFO
org.apache.cassandra DEBUG
Cassandra Change Log Level
You can use the nodetool setlogginglevel command to change the logging level for a specific framework.
The command syntax is as shown:
Cassandra supports the following log levels:
- ALL
- TRACE
- DEBUG
- INFO (Default)
- WARN
- ERROR
- OFF
For example, to change the org.apache.cassandra framework log level to ALL, we can run the command as:
The previous command increases the log level to ALL. You can verify with the following command:
Output:
ROOT INFO
org.apache.cassandra ALL
We can see that the log level has changed to ALL.
We can also increase the log level of other frameworks such as FailureDetector as follows:
The previous command enables the FailureDetector framework and set it to the specified log level.
Check Frameworks and Log Levels using the following command:
Output:
ROOT INFO
org.apache.cassandra ALL
org.apache.cassandra.gms.FailureDetector INFO
Ensure that you have a permission to add the log frameworks in your cluster.
NOTE: You can also edit the logback.xml file to modify the log level of a specific framework. For example, to modify the log level of the org.apache.cassandra framework, use the following command:
Edit the following value and set your target log level:
Making changes to the configuration file may require you to restart the Cassandra service.
Conclusion
In this article, you discovered how to use the nodetool to view and manage the log levels of the various frameworks in a Cassandra cluster.
Thanks for reading!