1.以wordcount为例

package org.apache.spark.examples

import org.apache.spark.examples.SparkPi.logger
import org.apache.spark.{SparkConf, SparkContext} object word { private val logger = org.slf4j.LoggerFactory.getLogger(this.getClass)
def main(args: Array[String]) {
val conf = new SparkConf()
.setAppName("WordCount").setMaster("local")
val sc = new SparkContext(conf)
logger.info("this is textFile1" )
println("this is textFile2print")
logger.error("this is textFile3err")
logger.warn("this is textFile4warn")
logger.debug("this is textFile5debug")
val lines = sc.textFile("E:\\spark_file\\wordcount.txt", )
val words = lines.flatMap { line => line.split(" ") }
val pairs = words.map { word => (word, ) }
val wordCounts = pairs.reduceByKey { _ + _ }
wordCounts.foreach(wordCount => println(wordCount._1 + " appeared " + wordCount._2 + " times."))
}
}

2.控制台输出结果:

scala打印error,debug,info的更多相关文章

  1. Solve Error Debug Assertion Failed Expression vector iterators incompatible Using PCL in Release Mode of VS2010

    When using PCL 1.4.0 in the release mode building under VS2010, we might sometime get the error &quo ...

  2. scala打印九九乘法表的5种实现

    使用scala打印九九乘法表,可以有多种实现方法,实现的过程充分的体现的scala语言的优势和巨大的简洁性和高效性, 下面我用了5种方法实现九九乘法表. 使用类似于java,c++等指令风格的的编程实 ...

  3. Scala Java Error: value filter is not a member of *

    有时在Scala中调用Java的库,Java库会返回某些Java的集合或类型,必须经过一些转换才能正常使用. 否则有可能在编译的过程遇到这个错误. 错误字符串 下面是错误的主要信息. Scala Ja ...

  4. NodeJS学习笔记 进阶 (11)Nodejs 进阶:调试日志打印:debug模块

    个人总结:读完这篇文章需要5分钟,讲解了debug模块的使用 摘选自网络 前言 在node程序开发中时,经常需要打印调试日志.用的比较多的是debug模块,比如express框架中就用到了.下文简单举 ...

  5. Objective-C与Swift下的自定义打印函数(Debug和Release)

    1.Objective-C 在使用Objective-C进行开发的过程中,为了Debug会不断的设置打印函数.如下图是我们经常用的,用来测试监听方法的实现与否: NSLog(@"%s&quo ...

  6. idea 运行scala代码 报错:Exception in thread "main" java.lang.NoClassDefFoundError: scala/Predef$ java.lang.NoClassDefFoundError: scala/Function0 Error: A JNI error has occurred, please check your installati

    各种报错信息如下: java.lang.NoClassDefFoundError: scala/Function0 at java.lang.Class.getDeclaredMethods0(Nat ...

  7. ZThread在Windows下打印若干DEBUG信息到console的原因

    代码见这篇随笔 在Windows下的运行结果:ZThread打印了一堆东西(并不是我写的) 文件结构: 最开始我以为是编译选项没弄对,同样的代码放到Linux下编译,还是打印这些信息 注意我在Linu ...

  8. C++ error:Debug Assertion Failed.Expression:_BLOCK_TYPE_IS_VALID(phead->nBlock)

    Debug Assertion Failed.Expression:_BLOCK_TYPE_IS_VALID(phead->nBlockUse) 关于上面这个错误,我在上一篇文章中的程序遇到过了 ...

  9. error: [debug/qrc_resource.cpp] Error 1

    t在进行debug时,出现这个错误,去资源文件夹,用资源编辑器打开resource.qrc文件,查看是否有标红的资源文件. 如果有红色名称的资源文件,那么就是因为缺少该资源文件,导致的这个错误. 改正 ...

随机推荐

  1. JavaScript语句-流程控制语句

    JavaScript定义了一组语句,语句通常用于执行一定的任务.语句可以很简单,也可以很复杂. 选择结构,可以在程序中创建交叉结构来指定程序流的可能方向.JavaScript中有四种选择结构: 1.单 ...

  2. 【bzoj2753】[SCOI2012]滑雪与时间胶囊

    #include<algorithm> #include<iostream> #include<cstdlib> #include<cstring> # ...

  3. easyui表格格线错位

    现象:如果easyui表格中存在后渲染的linkbutton,则可能会导致表格固定列的格线与内容列的格线不一致,出现这种情况的原因是在表格的onLoadSuccess事件中渲染linkbutton时, ...

  4. hadoop-3.0.0-alpha4安装部署过程

    关闭防火墙 #systemctl stop firewalld.service #停止firewall #systemctl disable firewalld.service #禁止firewall ...

  5. openfire重新配置数据库oracle、mysql

    1.openfire重新配置设置: 删除target/openfire/conf/openfire.xml中的 <setup>true</setup> 2.删除浏览器之前访问过 ...

  6. 【SCOI 2005】 扫雷

    [题目链接] 点击打开链接 [算法] 只要第一行第一个数确定了,后面的数也都确定了 递推两遍即可 [代码] #include<bits/stdc++.h> using namespace ...

  7. bzoj 1731 Layout 排队布局 —— 差分约束

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1731 差分约束: ML: dis[y] - dis[x] <= k,即 x 向 y 连 ...

  8. 《JAVA与模式》之迭代子模式

    迭代子模式又叫游标(Cursor)模式,是对象的行为模式.迭代子模式可以顺序地访问一个聚集中的元素而不必暴露聚集的内部表象(internal representation). 聚集和JAVA聚集 多个 ...

  9. jQuery得到多个值只能用取Class ,不能用取ID

    如果页面有多个checkbox: <input type="checkbox"   class="checkApply"    id="chec ...

  10. (转)Javascript中console.log()用法

    原文地址应该是这个吧:http://my.oschina.net/junn/blog/142728 注意:必须要提前打开IE的开发者模式才能看到输入 否则就会报错. IE下可以这个判断: if (co ...