增加log4j日志的两种方法

原创 2016年05月30日 11:06:45

一种是如下配置,但这种较为复杂,我配置的时候出现过内部类的日志没有写入的问题,尚未搞清楚原因,即在原有配置文件中追加:

#CentralizedReceivedServer
log4j.logger.org.apache.hama.bsp.message.CentralizedMessageReceiveServer=INFO,centralLogger
log4j.appender.centralLogger=org.apache.log4j.FileAppender
log4j.appender.centralLogger.File=/opt/hama-0.7.1/logs/Central.log
log4j.appender.centralLogger.layout=org.apache.log4j.PatternLayout
log4j.appender.centralLogger.layout.ConversionPattern=%d %p [%c] - %m%n
log4j.additivity.centralLogger=false  //表明本输入日志中不加入rootLogger中的日志数据,而是单独的一个输出

#RPC Server
log4j.logger.org.apache.hama.ipc.Server=INFO,centralLogger
log4j.logger.org.apache.hama.ipc.Server.Listener=INFO,centralLogger
</pre><pre code_snippet_id="1701345" snippet_file_name="blog_20160530_6_1542532" name="code" class="java">
</pre>另外一种则是直接在该进程的启动进程脚本中写入日志对应文件:<p></p><p></p><pre code_snippet_id="1701345" snippet_file_name="blog_20160530_5_2240643" name="code" class="java">#!/usr/bin/env bash

/home/liuqiang2/jdk/jdk1.7.0_79/bin/java -Xmx2048m -Dhama.log.dir=/opt/hama-0.7.1/bin/../logs 
-Dhama.log.file=centralLogger.log
-Dhama.home.dir=/opt/hama-0.7.1/bin/.. -Dhama.id.str=liuqiang2 -Dhama.root.logger=INFO,DRFA -Dhama.policy.file=hama-policy.xml 


</pre><pre code_snippet_id="1701345" snippet_file_name="blog_20160530_7_877440" name="code" class="java">-classpath /opt/hama-0.7.1/bin/../conf:/home/liuqiang2/jdk/jdk1.7.0_79/lib/tools.jar:/opt/hama-0.7.1/bin/../hama-commons-0.7.1.jar:/opt/hama-0.7.1/bin/../hama-core-0.7.1.jar:/opt/hama-0.7.1/bin/../hama-examples-0.7.1.jar:/opt/hama-0.7.1/bin/../hama-graph-0.7.1.jar:/opt/hama-0.7.1/bin/../hama-mesos-0.7.1.jar:/opt/hama-0.7.1/bin/../hama-ml-0.7.1.jar:/opt/hama-0.7.1/bin/../hama-yarn-0.7.1.jar:/opt/hama-0.7.1/bin/../lib/activation-1.1.jar:/opt/hama-0.7.1/bin/../lib/ant-1.6.5.jar:/opt/hama-0.7.1/bin/../lib/ant-1.7.1.jar:/opt/hama-0.7.1/bin/../lib/ant-launcher-1.7.1.jar:/opt/hama-0.7.1/bin/../lib/aopalliance-1.0.jar:/opt/hama-0.7.1/bin/../lib/apacheds-i18n-2.0.0-M15.jar:/opt/hama-0.7.1/bin/../lib/apacheds-kerberos-codec-2.0.0-M15.jar:/opt/hama-0.7.1/bin/../lib/api-asn1-api-1.0.0-M20.jar:/opt/hama-0.7.1/bin/../lib/api-util-1.0.0-M20.jar:/opt/hama-0.7.1/bin/../lib/asm-3.1.jar:/opt/hama-0.7.1/bin/../lib/avro-1.5.3.jar:/opt/hama-0.7.1/bin/../lib/commons-beanutils-1.8.3.jar:/opt/hama-0.7.1/bin/../lib/commons-cli-1.2.jar:/opt/hama-0.7.1/bin/../lib/commons-codec-1.4.jar:/opt/hama-0.7.1/bin/../lib/commons-collections-3.2.1.jar:/opt/hama-0.7.1/bin/../lib/commons-compress-1.9.jar:/opt/hama-0.7.1/bin/../lib/commons-configuration-1.7.jar:/opt/hama-0.7.1/bin/../lib/commons-daemon-1.0.13.jar:/opt/hama-0.7.1/bin/../lib/commons-digester-1.8.1.jar:/opt/hama-0.7.1/bin/../lib/commons-httpclient-3.0.1.jar:/opt/hama-0.7.1/bin/../lib/commons-io-2.4.jar:/opt/hama-0.7.1/bin/../lib/commons-lang-2.6.jar:/opt/hama-0.7.1/bin/../lib/commons-logging-1.1.1.jar:/opt/hama-0.7.1/bin/../lib/commons-math3-3.0.jar:/opt/hama-0.7.1/bin/../lib/commons-net-3.1.jar:/opt/hama-0.7.1/bin/../lib/core-3.1.1.jar:/opt/hama-0.7.1/bin/../lib/curator-client-2.7.1.jar:/opt/hama-0.7.1/bin/../lib/curator-framework-2.7.1.jar:/opt/hama-0.7.1/bin/../lib/curator-recipes-2.7.1.jar:/opt/hama-0.7.1/bin/../lib/geronimo-annotation_1.0_spec-1.0.jar:/opt/hama-0.7.1/bin/../lib/geronimo-spec-jta-1.0.1B-rc4.jar:/opt/hama-0.7.1/bin/../lib/gson-2.2.4.jar:/opt/hama-0.7.1/bin/../lib/guava-13.0.1.jar:/opt/hama-0.7.1/bin/../lib/guice-3.0.jar:/opt/hama-0.7.1/bin/../lib/guice-servlet-3.0.jar:/opt/hama-0.7.1/bin/../lib/hadoop-annotations-2.7.0.jar:/opt/hama-0.7.1/bin/../lib/hadoop-auth-2.7.0.jar:/opt/hama-0.7.1/bin/../lib/hadoop-common-2.7.0.jar:/opt/hama-0.7.1/bin/../lib/hadoop-hdfs-2.7.0.jar:/opt/hama-0.7.1/bin/../lib/hadoop-hdfs-2.7.0-tests.jar:/opt/hama-0.7.1/bin/../lib/hadoop-mapreduce-client-core-2.7.0.jar:/opt/hama-0.7.1/bin/../lib/hadoop-yarn-api-2.7.0.jar:/opt/hama-0.7.1/bin/../lib/hadoop-yarn-client-2.7.0.jar:/opt/hama-0.7.1/bin/../lib/hadoop-yarn-common-2.7.0.jar:/opt/hama-0.7.1/bin/../lib/htrace-core-3.1.0-incubating.jar:/opt/hama-0.7.1/bin/../lib/httpclient-4.2.5.jar:/opt/hama-0.7.1/bin/../lib/httpcore-4.1.2.jar:/opt/hama-0.7.1/bin/../lib/jackson-core-asl-1.9.2.jar:/opt/hama-0.7.1/bin/../lib/jackson-jaxrs-1.8.3.jar:/opt/hama-0.7.1/bin/../lib/jackson-mapper-asl-1.9.2.jar:/opt/hama-0.7.1/bin/../lib/jackson-xc-1.8.3.jar:/opt/hama-0.7.1/bin/../lib/javax.inject-1.jar:/opt/hama-0.7.1/bin/../lib/java-xmlbuilder-0.4.jar:/opt/hama-0.7.1/bin/../lib/jaxb-api-2.2.2.jar:/opt/hama-0.7.1/bin/../lib/jaxb-impl-2.2.3-1.jar:/opt/hama-0.7.1/bin/../lib/jdk.tools-1.7.jar:/opt/hama-0.7.1/bin/../lib/jersey-client-1.9.jar:/opt/hama-0.7.1/bin/../lib/jersey-core-1.9.jar:/opt/hama-0.7.1/bin/../lib/jersey-guice-1.9.jar:/opt/hama-0.7.1/bin/../lib/jersey-json-1.9.jar:/opt/hama-0.7.1/bin/../lib/jersey-server-1.9.jar:/opt/hama-0.7.1/bin/../lib/jets3t-0.9.0.jar:/opt/hama-0.7.1/bin/../lib/jettison-1.1.jar:/opt/hama-0.7.1/bin/../lib/jetty-6.1.14.jar:/opt/hama-0.7.1/bin/../lib/jetty-annotations-6.1.14.jar:/opt/hama-0.7.1/bin/../lib/jetty-plus-6.1.14.jar:/opt/hama-0.7.1/bin/../lib/jetty-util-6.1.14.jar:/opt/hama-0.7.1/bin/../lib/jline-0.9.94.jar:/opt/hama-0.7.1/lib/commons-logging-1.1.1.jar:/opt/hama-0.7.1/lib/slf4j-log4j12-1.5.8.jar:/opt/hama-0.7.1/lib/slf4j-api-1.5.8.jar:/opt/hama-0.7.1/lib/log4j-1.2.16.jar:/opt/hama-0.7.1/lib/leveldbjni-all-1.8.jar:/opt/hama-0.7.1/lib/protobuf-java-2.5.0.jar:/opt/hama-0.7.1/   org.apache.hama.bsp.message.CentralizedMessageReceiveServer &






版权声明:本文为博主原创文章,未经博主允许不得转载。 举报

相关文章推荐

在项目中添加日志,Log4j,相关配置

一,首先导入相关jar包:log4j-1.2.16.jar,slf4j-log4j12-1.7.2.jar, 二、配置log4j.properties ### direct log message...

log4j以不同的级别往不同文件(屏幕)打印日志的方法

log4j以不同的级别在不同文件里或者文件里与屏幕上打印日志的方法

我是如何成为一名python大咖的?

人生苦短,都说必须python,那么我分享下我是如何从小白成为Python资深开发者的吧。2014年我大学刚毕业..

记录下log4j的两种配置方式

XML文件配置 <appender nam

log4j日志两种简单的使用方式

一直以来只知道用log4j这个日志工具包,对他的配置文件也从来没有去解读过,至于它的用法也一直都是复制粘贴,今天在参考了大牛的博客,发现它有两种使用方式 第一种:先看log4j.properties文...

Log4j的两种配置

如下的内容转载自:http://blog.csdn.NET/snakeqi/article/details/5183070 一、Log4j简介 Log4j有三个主要的组件:Logg...

android两种日志获取log4j

android log4j日志框架使用

log4j日志的使用步骤和基本技术知识

log4j日志的使用步骤和基本技术知识

log4j日志的应用

日志是应用软件中不可缺少的部分,Apache的开源项目Log4j是一个功能强大的日志组件,提供方便的日志记录。以下是个人经验,具体请参考Log4j文档指南。 Log4j下载 在apac...
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)