karan1001
karan1001

Reputation: 121

Datastax Cassandra 2.2.5: Change Logging Location (logback)

i am using datastax cassandra 2.2.5 on a ubuntu server. The logging configuration seems to be in the "/etc/cassandra/logback.xml" file. In this xml, the destination folder for the log files is set via the "${cassandra.logdir}" property. Where should i configure/change this property so that i can give a custom folder location? I do 'not' want my logs to go to the default location "/var/log/cassandra".

I also tried updated the cassandra-env.sh, with "JVM_OPTS="$JVM_OPTS -Dcassandra.logdir=/data/log" But now there are two system setting with different folders. Thus my folder location is not overriding the default folder. Thanks jaskaran

Upvotes: 2

Views: 1386

Answers (1)

doanduyhai
doanduyhai

Reputation: 8812

Ok after reading the logback docs: http://logback.qos.ch/manual/configuration.html#variableSubstitution

It says that variables in logback.xml are resolved against different scope, in this order:

  • local scope
  • context scope
  • system scope

In our case, it's is the system scope that is used.

The cassandra.logdir is set inside the /usr/sbin/cassandra exec file itself:

launch_service()
{
    pidpath="$1"
    foreground="$2"
    props="$3"
    class="$4"
    cassandra_parms="-Dlogback.configurationFile=logback.xml"
    cassandra_parms="$cassandra_parms -Dcassandra.logdir=/var/log/cassandra"
    cassandra_parms="$cassandra_parms -Dcassandra.storagedir=$cassandra_storagedir"
...
...

As you can see, the storagedir variable can be defined by user (in the file /usr/share/cassandra/cassandra.in.sh) but it seems that cassandra.logdir is hard-coded.

Just change it there or add a variable $cassandra.logdir so you can defined it in /usr/share/cassandra/cassandra.in.sh which is less instrusive than modifying the cassandra exec

Upvotes: 3

Related Questions