Newbie needs help: what is "log4j:WARN No appenders could be found for logger (com.datastax.driver.core.SystemProperties)." ???

1,339 views
Skip to first unread message

Hakim

unread,
Jul 4, 2015, 4:02:08 PM7/4/15
to spark-conn...@lists.datastax.com
Hi,

I'm learning the basics of Cassandra and connecting to it using the datastax drive (java). I've successfully connected to a test cluster I setup on my local machine. However, I keep getting this warning when I run my very simple connection script (IntelliJ IDEA).


"log4j:WARN No appenders could be found for logger (com.datastax.driver.core.SystemProperties)."

I've searched around but can not find a good solution. Anyone know what is going on here?

thank you,

Hakim,

Venky Kandaswamy

unread,
Jul 4, 2015, 6:42:06 PM7/4/15
to spark-conn...@lists.datastax.com
Hakim,
This has nothing to do with Cassandra. You need to tell log4j where to
write its logs. For example:

# A1 is set to be a ConsoleAppender.
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss}]
[%t] %-5p %c{1} - %m%n

# A1 uses the file formatter
log4j.appender.FILE=org.apache.log4j.RollingFileAppender
log4j.appender.FILE.File=cassandra2hdfs.log
log4j.appender.FILE.Append=true
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.MaxFileSize=200MB
log4j.appender.FILE.MaxBackupIndex=10
log4j.appender.FILE.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss}]
[%t] %-5p %c{1} - %m%n


You should add these entries to the log4j.properties file. Make sure
you use the right file (I.e the first one that will be found in your class
path). By default this would be the one in your src/java/resources. Also,
the Cassandra driver uses SLF4J.

Venky
@WalmartLabs

On 7/4/15, 1:02 PM, "Hakim" <spark-conn...@lists.datastax.com on
>To unsubscribe from this group and stop receiving emails from it, send an
>email to spark-connector-...@lists.datastax.com.


Venky Kandaswamy

unread,
Jul 5, 2015, 10:05:12 AM7/5/15
to spark-conn...@lists.datastax.com
I did not do anything special - but here are the basics. Note that if you
are using VPN, especially on Macs, it may be creating a tunnel and
disabling traffic to your main ethernet port. You may have to hardcode the
local IP address in the spark-env.sh as follows:

SPARK_LOCAL_IP=127.0.0.1
SPARK_MASTER_IP=127.0.0.1

Other than this, nothing special is needed.


L-SNVL12EFD5-M:spark-1.4.0-bin-hadoop2.6 vkandas$ ./bin/spark-shell --jars
/Users/vkandas/Documents/Workspace/spark-cassandra-connector/spark-cassand
ra-connector-java/target/scala-2.10/spark-cassandra-connector-java-assembly
-1.4.0-M1-SNAPSHOT.jar --conf
spark.cassandra.connection.host=dev-cas00.sv.walmartlabs.com
log4j:WARN No appenders could be found for logger
(org.apache.hadoop.metrics2.lib.MutableMetricsFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for
more info.
Using Spark's default log4j profile:
org/apache/spark/log4j-defaults.properties
15/07/05 06:39:30 INFO SecurityManager: Changing view acls to: vkandas
15/07/05 06:39:30 INFO SecurityManager: Changing modify acls to: vkandas
15/07/05 06:39:30 INFO SecurityManager: SecurityManager: authentication
disabled; ui acls disabled; users with view permissions: Set(vkandas);
users with modify permissions: Set(vkandas)
15/07/05 06:39:30 INFO HttpServer: Starting HTTP Server
15/07/05 06:39:30 INFO Utils: Successfully started service 'HTTP class
server' on port 63927.
Welcome to
____ __
/ __/__ ___ _____/ /__
_\ \/ _ \/ _ `/ __/ '_/
/___/ .__/\_,_/_/ /_/\_\ version 1.4.0
/_/


Using Scala version 2.10.4 (Java HotSpot(TM) 64-Bit Server VM, Java
1.8.0_45)
Type in expressions to have them evaluated.
Type :help for more information.
15/07/05 06:39:31 INFO SparkContext: Running Spark version 1.4.0

Š


scala> import com.datastax.spark.connector._
import com.datastax.spark.connector._


scala> val stg = sc.cassandraTable("qarth_catalog_dev", "product_v1")
stg:
com.datastax.spark.connector.rdd.CassandraTableScanRDD[com.datastax.spark.c
onnector.CassandraRow] = CassandraTableScanRDD[0] at RDD at
CassandraRDD.scala:15


scala> stg.first()

15/07/05 06:56:22 INFO DAGScheduler: Job 0 finished: take at
CassandraRDD.scala:118, took 1.863234 s
res0: com.datastax.spark.connector.CassandraRow = CassandraRow{wpid:
66MKDP7AWAFV, tenant_id: 0, update_date_time:
e2ade340-d008-11e4-a44f-11a51653aa7f, product_source: WALMART_DOTCOM,
product_status: PRODUCT_PROCESSED, source_id: 14018328, value:
{"qid":"WALMART_DOTCOM#14018328","type":"PRODUCT","source":"WALMART_DOTCOM"
,"classification":{"PRODUCT_TYPE":{"product_category":{"properties":{"attri
buteName":"Product
Category","taxonomy_version":"urn:taxonomy:pcs2.0","status":"VERIFIED"},"va
lues":[{"id":"45066","locale":"en_US","value":"Home &
Garden"}]},"product_type":{"properties":{"attributeName":"Product
Type","taxonomy_version":"urn:taxonomy:pcs2.0","status":"VERIFIED"},"values
":[{"id":"635","locale":"en_US","value":"Ottomans"}]}}},"status":"PRODUCT_P
ROCESSED","request_id":"e1fd7350-d3...
scala> 15/07/05 06:56:22 INFO CassandraConnector: Disconnected from
Cassandra cluster: Dev Cluster



‹‹‹‹‹‹‹‹‹‹

Or, you can use data frames like:

scala> val df = sqlContext.load("org.apache.spark.sql.cassandra", options
= Map( "table" -> "product_v1", "keyspace" -> "qarth_catalog_dev" ))


And then do df.first(), df.count() etc.

Data frames appear to be really slow compared to the direct cassandraTable
method above.

Venky
@WalmartLabs

On 7/4/15, 1:02 PM, "Hakim" <spark-conn...@lists.datastax.com on
behalf of keam...@gmail.com> wrote:

Hakim Fajardo

unread,
Jul 5, 2015, 10:16:09 AM7/5/15
to spark-conn...@lists.datastax.com
Thank you! I checked in my src/Java/resources path but no log4j.properties file. So I created one and pasted the appended info below and checked on datastax page about log4j settings. Still getting warning...do I need to import log4j into my CassandraConnect class? 
Reply all
Reply to author
Forward
0 new messages