Apache Cassandra

Cassandra Set Log Level

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:

  1. 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.
  2. 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.
  3. 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:

$ nodetool getlogginglevels

The command should return the log name and the currently set log level. An example output is shown in the following:

Logger Name                                        Log Level
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:

$ nodetool setlogginglevel <framework> <log_level>

Cassandra supports the following log levels:

  1. ALL
  2. TRACE
  3. DEBUG
  4. INFO (Default)
  5. WARN
  6. ERROR
  7. OFF

For example, to change the org.apache.cassandra framework log level to ALL, we can run the command as:

$ nodetool setlogginglevel org.apache.cassandra ALL

The previous command increases the log level to ALL. You can verify with the following command:

$ nodetool getlogginglevels

Output:

Logger Name                                        Log Level
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:

$ nodetool setlogginglevel org.apache.cassandra.gms.FailureDetector INFO

The previous command enables the FailureDetector framework and set it to the specified log level.

Check Frameworks and Log Levels using the following command:

$ nodetool getlogginglevels

Output:

Logger Name                                        Log Level
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:

<logger name="org.apache.cassandra" level="DEBUG"/>

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!

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list