DataStax Help Center

FAQ - How to configure logging to non-default locations

Summary

Typically Apache Cassandra will log to /var/log/cassandra. This article discusses how to setup logging in DSE to log to non-default locations

Solution

Note: changing the default log location will affect gathering of logs by the OpsCenter agent for diagnostic purposes. For more information refer to the docs for setting the log location for the OpsCenter agent.

Ensure the target directories have the right permissions for the user running the Cassandra process (usually "cassandra")

One can either set the variables outside or inside of the dse startup scripts as outlined below

Setting the env variables outside of the dse startup scripts:

The variables can be set in the shell or in the user's profile bashrc file for example

$ export CASSANDRA_LOG_DIR=/mnt1/cassandra/logs

$ export DSE_LOG_ROOT=/mnt1/cassandra/logs

 

Setting the env variables inside the dse startup scripts:

The dse.in.sh typically has two places where these are checked and then set. To override any defaults, it is simply a matter of setting these to the required value before the checks.

Example from DSE4.8.5 tarball installation (note some versions may have subtle differences):

export CASSANDRA_LOG_DIR=/mnt1/cassandra/logs

export DSE_LOG_ROOT=/mnt1/cassandra/logs

...

if [ -z "$CASSANDRA_LOG_DIR" ]; then
export CASSANDRA_LOG_DIR="/var/log/cassandra"
fi

...

if [ -z "$DSE_LOG_ROOT" ]; then
    DSE_LOG_ROOT_DEFAULT="/var/log"
    if [ -w "$DSE_HOME/logs" ]; then
        export DSE_LOG_ROOT="$DSE_HOME/logs"
    else
        export DSE_LOG_ROOT="$DSE_LOG_ROOT_DEFAULT"
    fi
fi

 

Setting the output.log

This typically differs in tarball and package installations. The output.log is echoed to stdout in tarball installs. This can therefore be redirected to a suitable location as required

./dse-4.8.5/bin/dse cassandra &> ./dse-4.8.5/mylogs/output.log

For package installations edit the /etc/default/dse file:

# Location of log output
OUTPUT_FILE="/logs/output.log"

 

A restart of DSE will be required in all cases to invoke the changes

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

  • Avatar
    Barrie Byron

    Mark, this is very helpful! Adding to DSE docs. Please remember to share with the docs team new posts with helpful information like this.

Powered by Zendesk