R:让STFU获得繁琐的Java流程
作者:互联网
我正在使用rJava从R内部与Amazon Web Services Java API对话.经过一些初步的痛苦,我有它的工作.但是API非常繁琐并向R反馈大量的信息,这对于调试非常有用,但是现在我的代码工作了,我想让这个信息喋喋不休.我该如何摆脱这种喋喋不休?我甚至不确定在哪里看. API? rJava? R中的开关?
任何在哪里看的帮助将不胜感激.这是信息聊天的一个例子:
R> result <- uploadS3File(clusterObject$s3TempDir, streamFile)
Dec 17, 2010 12:12:52 PM com.amazonaws.http.HttpClient execute
INFO: Sending Request: PUT https://rtmphgdfkoughcboh8kl.s3.amazonaws.com /stream.txt Headers: (Authorization: AWS AKIAIC2FRTLFVNIOTMAQ:E++Z54SQsgoAntZ7JAd6aWJ2ZVs=, Date: Fri, 17 Dec 2010 18:12:52 GMT, Content-Length: 255579, Content-MD5: pMFNOWPJswXpAEULjfOclw==, Content-Type: text/plain, )
Dec 17, 2010 12:12:53 PM com.amazonaws.http.HttpClient handleResponse
INFO: Received successful response: 200, AWS Request ID: FC4113F003FCF631
R>
解决方法:
Jeffrey Breen’s回答指出了我正确的方向.我在log4j上做了一些挖掘,并发现,thanks to the AWS forum,Java AWS API没有设置log4j,但它真的很容易添加.我所要做的就是将文件log4j-1.2.16.jar添加到我的类路径中.然后我使用the examples in the API docs创建了一个log4J.properties文件.然后我添加了将我的log4j.properties文件放到classpath中的目录,它工作正常!
所以我的.onLoad()函数的第一部分看起来像这样:
.onLoad <- function(lib, pkg) {
pathToSdk <- paste(system.file(package = "segue") , "/aws-java-sdk/", sep="")
jarPaths <- c(paste(pathToSdk, "lib/aws-java-sdk-1.1.0.jar", sep=""),
paste(pathToSdk, "third-party/commons-logging-1.1.1/commons-logging-1.1.1.jar", sep=""),
paste(pathToSdk, "third-party/commons-httpclient-3.0.1/commons-httpclient-3.0.1.jar", sep=""),
paste(pathToSdk, "third-party/commons-codec-1.3/commons-codec-1.3.jar", sep=""),
paste(pathToSdk, "third-party/log4j-1.2.16.jar", sep=""),
paste(pathToSdk, "third-party/", sep="")
)
.jpackage(pkg, morePaths=jarPaths)
## other stuff edited out
}
我的log4j.properties文件中有这个:
log4j.rootLogger=WARN, A1
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
我的log4j.properties文件位于第三方/目录中,您可以在类路径中看到它.
标签:java,r,rjava 来源: https://codeday.me/bug/20190610/1212069.html