注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

阿弥陀佛

街树飘影未见尘 潭月潜水了无声 般若观照心空静...

 
 
 

日志

 
 
关于我

一直从事气象预报、服务建模实践应用。 注重气象物理场、实况场、地理信息、本体知识库、分布式气象内容管理系统建立。 对Barnes客观分析, 小波,计算神经网络、信任传播、贝叶斯推理、专家系统、网络本体语言有一定体会。 一直使用Java、Delphi、Prolog、SQL编程。

网易考拉推荐

Akka with logback  

2015-09-19 17:03:54|  分类: Akka |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

Logback Project
logback github
akka.io
开发基于Akka的日志应用,需要:
1.jar包
akka-actor.jar
config.jar
akka-slf4j.jar
logback-classic.jar
logback-core.jar
==================================
2. src/main/resources
application.conf
logback.xml
-------------------------------------------------------------
application.conf
akka{
loggers = ["akka.event.slf4j.Slf4jLogger"]
# Options: ERROR, WARNING, INFO, DEBUG
loglevel = "INFO"
}
logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>

<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logs/akka.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>50MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>

<root level="INFO">
<appender-ref ref="FILE"/>
<appender-ref ref="STDOUT"/>
</root>
</configuration>
应用:
package test

import test.TeacherProtocol.{QuoteResponse, QuoteRequest}
import akka.actor.Actor
import akka.actor.ActorLogging
/*
* Teacher with Logging
*
*/
class TeacherLogActor extends Actor with ActorLogging {
val quotes = List(
"Moderation is for cowards",
"Anything worth doing is worth overdoing",
"The trouble is you think you have time",
"You never gonna know if you never even try")

def receive = {
case QuoteRequest => {
import util.Random
//get a random element (for now)
val msg = quotes(Random.nextInt(quotes.size))
val quoteResponse=QuoteResponse(msg)
log.info(quoteResponse.toString())
log.debug(quoteResponse.toString())
log.error("error test")
log.info("Quote printed") //This message is just to assert from the testcase
}
}
def quoteList=quotes
}

17:47:03.236 [UniversityMessageSystem-akka.actor.default-dispatcher-4] INFO  akka.event.slf4j.Slf4jLogger - Slf4jLogger started
17:47:03.269 [UniversityMessageSystem-akka.actor.default-dispatcher-4] INFO  test.TeacherLogActor - QuoteResponse(The trouble is you think you have time)
17:47:03.273 [UniversityMessageSystem-akka.actor.default-dispatcher-4] ERROR test.TeacherLogActor - error test
17:47:03.274 [UniversityMessageSystem-akka.actor.default-dispatcher-4] INFO  test.TeacherLogActor - Quote printed

Process finished with exit code 0
  评论这张
 
阅读(253)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017