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. base64和图片互转

    pom.xml添加 <!-- https://mvnrepository.com/artifact/commons-codec/commons-codec --> <dependen ...

  2. YTU 2979: MathBook类--多态

    2979: MathBook类--多态 时间限制: 1 Sec  内存限制: 128 MB 提交: 51  解决: 31 题目描述 Book类将自己的display函数设计为虚函数,从而通过父类指针调 ...

  3. 疯狂JAVA——数组

    java是静态语言,java数组也是静态语言 静态初始化: String[] a = new String[]{ "我"}; String[] b = { "你" ...

  4. 如何在Android studio中同时打开多个工程?

    最近学习Android Studio,想同时打开两个Project.但是点击File->Open之后,原有的Project被关闭掉了.怎么在新的窗口中打开Project呢? 解决: 点击Help ...

  5. 深度学习 dns tunnel检测 使用统计特征 全连接网络——精度99.8%

    代码如下: import numpy as np import tflearn from tflearn.layers.core import dropout from tflearn.layers. ...

  6. idea如何将普通文件夹转成java项目root目录/maven

    转java项目 转maven 选中pom文件右键就能看到了

  7. Java总结基础知识

    权限关键字: public:可以被所有其他类所访问,不同的包 protected:当前类的成员.同一个包中.不同包中对子类可见父类protected,继承类 default:同一包中的类可以访问,声明 ...

  8. 【HAOI 2006】 受欢迎的牛

    [题目链接] 点击打开链接 [算法] 先用tarjan缩点,然后找出度为零的点,即可 [代码] #include<bits/stdc++.h> using namespace std; # ...

  9. 【POJ 1947】 Rebuilding Roads

    [题目链接] 点击打开链接 [算法] f[i][j]表示以i为根的子树中,最少删多少条边可以组成j个节点的子树 树上背包,即可 [代码] #include <algorithm> #inc ...

  10. 服务器开发入门——理解异步I/O

    对于服务器程序,I/O是制约系统性能最关键的因素.对于需要处理大量连接的高并发服务器程序,异步I/O几乎是不二的选择.Linux和Windows都为异步I/O构建了大量的基础设施.本文总结了一下Lin ...