• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala LoggerContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Scala中ch.qos.logback.classic.LoggerContext的典型用法代码示例。如果您正苦于以下问题:Scala LoggerContext类的具体用法?Scala LoggerContext怎么用?Scala LoggerContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了LoggerContext类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。

示例1: Command

//设置package包名称以及导入依赖的类
package tech.artemisia.core

import java.nio.file.Paths
import ch.qos.logback.classic.LoggerContext
import ch.qos.logback.classic.joran.JoranConfigurator
import com.typesafe.config.Config
import org.slf4j.LoggerFactory
import tech.artemisia.config.{AppContext, AppSetting}
import tech.artemisia.core.dag.{ActorSysManager, Dag}
import tech.artemisia.task.TaskContext
import tech.artemisia.util.HoconConfigUtil.Handler



object Command {

  private def prepareAppContext(cmd_line_params: AppSetting) = {
    val appContext = new AppContext(cmd_line_params)
    configureLogging(appContext)
    AppLogger debug s"workflow_id: ${appContext.runId}"
    AppLogger debug s"working directory: ${appContext.workingDir}"
    if (appContext.globalConfigFile.nonEmpty) {
      AppLogger debug s"global config file: ${appContext.globalConfigFile.get}"
    }
    TaskContext.setWorkingDir(Paths.get(appContext.workingDir))
    TaskContext.predefinedConnectionProfiles = TaskContext.parseConnections(
      appContext.payload.as[Config](Keywords.Config.CONNECTION_SECTION))
    appContext
  }


  private def configureLogging(app_context: AppContext) = {
      val context = LoggerFactory.getILoggerFactory.asInstanceOf[LoggerContext]
      val jc = new JoranConfigurator
      jc.setContext(context)
      context.reset()
      context.putProperty("log.console.level", app_context.logging.console_trace_level)
      context.putProperty("log.file.level", app_context.logging.file_trace_level)
      context.putProperty("env.working_dir", app_context.coreSetting.working_dir)
      context.putProperty("workflow_id", app_context.runId)
      jc.doConfigure(this.getClass.getResourceAsStream("/logback_config.xml"))
  }


  def run(cmd_line_params: AppSetting) = {
    AppLogger info "request for run command acknowledged"
    val app_context = prepareAppContext(cmd_line_params)
    AppLogger debug "context object created"
    TaskContext.setWorkingDir(Paths.get(app_context.workingDir))
    val dag = Dag(app_context)
    AppLogger debug "starting Actor System"
    val actor_sys_manager =  new ActorSysManager(app_context)
    val workers = actor_sys_manager.createWorker(Keywords.ActorSys.CUSTOM_DISPATCHER)
    val dag_player = actor_sys_manager.createPlayer(dag,workers)
    dag_player ! 'Play
  }

  def doc(cmd_line_params: AppSetting) = {
  }

} 
开发者ID:gitter-badger,项目名称:artemisia,代码行数:62,代码来源:Command.scala


示例2: Logger

//设置package包名称以及导入依赖的类
package goahead

import java.net.URL

import ch.qos.logback.classic.LoggerContext
import ch.qos.logback.classic.joran.JoranConfigurator
import com.typesafe.scalalogging.LazyLogging
import org.slf4j.LoggerFactory

trait Logger extends LazyLogging
object Logger {
  def setLogConfFile(path: Either[URL, String]) = {
    val ctx = LoggerFactory.getILoggerFactory.asInstanceOf[LoggerContext]
    val conf = new JoranConfigurator
    conf.setContext(ctx)
    ctx.reset()
    path match {
      case Left(url) => conf.doConfigure(url)
      case Right(fileName) => conf.doConfigure(fileName)
    }
  }
} 
开发者ID:cretz,项目名称:goahead,代码行数:23,代码来源:Logger.scala


示例3: InstrumentLogging

//设置package包名称以及导入依赖的类
package microtools.metrics

import javax.inject.{Inject, Singleton}

import ch.qos.logback.classic.LoggerContext
import com.codahale.metrics.MetricRegistry
import com.codahale.metrics.logback.InstrumentedAppender
import org.slf4j.{Logger, LoggerFactory}

@Singleton
class InstrumentLogging @Inject()(metricRegistry: MetricRegistry) {
  InstrumentLogging.instrument(metricRegistry)
}

object InstrumentLogging {
  def instrument(metricRegistry: MetricRegistry): Unit = {
    val factory = LoggerFactory.getILoggerFactory.asInstanceOf[LoggerContext]
    val root    = factory.getLogger(Logger.ROOT_LOGGER_NAME)

    val instrumentedAppended = new InstrumentedAppender(metricRegistry)
    instrumentedAppended.setContext(root.getLoggerContext)
    instrumentedAppended.start()
    root.addAppender(instrumentedAppended)
  }
} 
开发者ID:21re,项目名称:play-micro-tools,代码行数:26,代码来源:InstrumentLogging.scala


示例4: Cmd

//设置package包名称以及导入依赖的类
import ch.qos.logback.classic.LoggerContext
import ch.qos.logback.classic.joran.JoranConfigurator
import command._
import org.slf4j.{Logger, LoggerFactory}

object Cmd extends CommandUtils {
  def commands: Map[String, () => Command] = Map(
    "archive" -> ArchiveCommand,
    "convert-month" -> ConvertMonthCommand,
    "convert-year" -> ConvertYearCommand,
    "get" -> GetCommand.apply,
    "info" -> InfoCommand,
    "update" -> UpdateCommand
  )

  def run(args: Array[String], isDev: Boolean): Unit = {
    if (args.length < 1) {
      println("Usage: <command> [parameters...]")
      println("Available commands: " + commands.keys.toVector.sorted.mkString(", "))
      sys.exit(-1)
    }

    val cmdName = args(0)
    val cmd: Command = commands.getOrElse(cmdName, exitError("Unknown command: " + cmdName))()

    configureLogback(
      if (isDev) "logback-dev.xml"
      else if (cmd.isVerbose) "logback-prod-verbose.xml" else "logback-prod.xml")

    val params: Array[String] = args.drop(1)
    val log: Logger = LoggerFactory.getLogger("main")
    log.info("Run: " + args.mkString(" "))
    cmd.run(log, params)
  }

  private def configureLogback(configFilename: String): Unit = {
    val configurator: JoranConfigurator = new JoranConfigurator
    val ctx: LoggerContext = LoggerFactory.getILoggerFactory.asInstanceOf[LoggerContext]
    configurator.setContext(ctx)
    ctx.reset()
    configurator.doConfigure(getClass.getClassLoader.getResource(configFilename))
  }

  def main(args: Array[String]) {
    run(args, isDev = false)
  }
} 
开发者ID:citrum,项目名称:log-server,代码行数:48,代码来源:Cmd.scala


示例5:

//设置package包名称以及导入依赖的类
package uk.ac.wellcome.test.utils

import ch.qos.logback.classic.LoggerContext
import ch.qos.logback.classic.joran.JoranConfigurator
import org.slf4j.LoggerFactory

trait StartupLogbackOverride {
  val loggerContext =
    LoggerFactory.getILoggerFactory.asInstanceOf[LoggerContext]
  loggerContext.reset
  val configurator = new JoranConfigurator
  configurator.setContext(loggerContext)
  configurator.doConfigure(
    getClass
      .getResourceAsStream("/logback-startup-test.xml"))
} 
开发者ID:wellcometrust,项目名称:platform-api,代码行数:17,代码来源:StartupLogbackOverride.scala


示例6: Log

//设置package包名称以及导入依赖的类
package faunadb.importer.report

import ch.qos.logback.classic.LoggerContext
import org.slf4j._

object Log {
  private val info = LoggerFactory.getLogger("info")
  private val error = LoggerFactory.getLogger("error")
  private val fatal = LoggerFactory.getLogger("fatal")

  @volatile private var statusLine: String = ""
  @volatile private var lastSize: Int = 0

  def info(msg: String): Unit = syncInfo(_.info(msg))
  def warn(msg: String): Unit = syncInfo(_.warn(s"[WARN] $msg"))

  private def syncInfo(f: Logger => Unit): Unit = {
    if (lastSize > 0) {
      synchronized {
        print(fillLine())
        f(info)
        print(statusLine)
      }
    } else {
      f(info)
    }
  }

  def status(line: String) {
    if (info.isInfoEnabled()) {
      synchronized {
        print(fillLine(line))
        lastSize = line.length
        statusLine = line
      }
    }
  }

  def clearStatus(): Unit = status("")

  private def fillLine(line: String = ""): String =
    s"\r\r$line${" " * Math.max(0, lastSize - line.length)}\r"

  def error(msg: String): Unit = error.error(msg)
  def fatal(err: Throwable): Unit = fatal.error(err.getMessage, err)

  def stop() {
    LoggerFactory.getILoggerFactory match {
      case c: LoggerContext => c.stop()
      case _                =>
    }
  }
} 
开发者ID:fauna,项目名称:faunadb-importer,代码行数:54,代码来源:Log.scala


示例7: InitialProcessing

//设置package包名称以及导入依赖的类
package io.iohk.iodb.bench

import java.io.File

import ch.qos.logback.classic.LoggerContext
import io.iohk.iodb.{ByteArrayWrapper, LSMStore, Store, TestUtils}
import org.slf4j.LoggerFactory


object InitialProcessing extends Benchmark {
  val Milestones = Seq(1000, 5000, 10000, 50000, 100000, 250000, 500000, 750000, 1000000)

  val Inputs = 5500
  //average number of inputs per block
  val Outputs = 6000 //average number of outputs per block

  def bench(store: Store, dir: File): Unit = {
    println(s"Store: $store")

    Milestones.foldLeft((0, 0L, Seq[ByteArrayWrapper]())) {
      case ((prevMilestone, prevTime, prevCache), milestone) =>
        val (time, newCache) = TestUtils.runningTime {
          (prevMilestone + 1 to milestone).foldLeft(prevCache) { case (cache, version) =>
            processBlock(version, store, Inputs, Outputs, cache).get.take(Inputs * 100)
          }
        }
        val newTime = prevTime + time
        println(s"Time  to get to $milestone: $time")
        (milestone, newTime, newCache)
    }

    store.close()
    TestUtils.deleteRecur(dir)
  }

  def main(args: Array[String]): Unit = {
    //switching off logging
    val context = LoggerFactory.getILoggerFactory.asInstanceOf[LoggerContext]
    context.stop()

    var dir = TestUtils.tempDir()
    bench(new LSMStore(dir, keySize = KeySize), dir)

    System.gc()
    Thread.sleep(15000)
    println("======================================")

    dir = TestUtils.tempDir()
    bench(new RocksStore(dir), dir)
  }
} 
开发者ID:input-output-hk,项目名称:iodb,代码行数:52,代码来源:InitialProcessing.scala


示例8: exit

//设置package包名称以及导入依赖的类
import turksem.qamr._
import turksem.util._
import turkey._
import turkey.tasks._
import akka.pattern.ask
import scala.concurrent.duration._
val annotationPath = java.nio.file.Paths.get("annotations")
implicit val timeout = akka.util.Timeout(5.seconds)
implicit val config: TaskConfig = {
  val isProduction = false // sandbox. change to true for production
  if(isProduction) {
    val hitDataService = new FileSystemHITDataService(annotationPath.resolve("production"))
    ProductionTaskConfig("qamr-emnlp2017", "localhost", hitDataService)
  } else {
    val hitDataService = new FileSystemHITDataService(annotationPath.resolve("sandbox"))
    SandboxTaskConfig("qamr-emnlp2017", "localhost", hitDataService)
  }
}
def exit = {
  // actor system has to be terminated for JVM to be able to terminate properly upon :q
  config.actorSystem.terminate
  // flush & release logging resources
  import org.slf4j.LoggerFactory
  import ch.qos.logback.classic.LoggerContext
  LoggerFactory.getILoggerFactory.asInstanceOf[LoggerContext].stop
  System.out.println("Terminated actor system and logging. Type :q to end.")
}

val setup = new emnlp2017.AnnotationSetup
val exp = setup.experiment
exp.server 
开发者ID:julianmichael,项目名称:mturk-semantics,代码行数:32,代码来源:init-emnlp.scala


示例9: exit

//设置package包名称以及导入依赖的类
import turksem.qamr._
import turksem.util._
import turkey._
import turkey.tasks._
import akka.pattern.ask
import scala.concurrent.duration._

val isProduction = false // sandbox. change to true for production
val domain = "nlp.cs.washington.edu" // change to your comain, or keep localhost for testing
val projectName = "qamr-ai2" // make sure it matches the SBT project;
// this is how the .js file is found to send to the server

val annotationPath = java.nio.file.Paths.get("annotations")
implicit val timeout = akka.util.Timeout(5.seconds)
implicit val config: TaskConfig = {
  if(isProduction) {
    val hitDataService = new FileSystemHITDataService(annotationPath.resolve("production"))
    ProductionTaskConfig(projectName, domain, hitDataService)
  } else {
    val hitDataService = new FileSystemHITDataService(annotationPath.resolve("sandbox"))
    SandboxTaskConfig(projectName, domain, hitDataService)
  }
}
def exit = {
  // actor system has to be terminated for JVM to be able to terminate properly upon :q
  config.actorSystem.terminate
  // flush & release logging resources
  import org.slf4j.LoggerFactory
  import ch.qos.logback.classic.LoggerContext
  LoggerFactory.getILoggerFactory.asInstanceOf[LoggerContext].stop
  System.out.println("Terminated actor system and logging. Type :q to end.")
}

val setup = new ai2.Ai2AnnotationSetup
val exp = setup.experiment
exp.server 
开发者ID:julianmichael,项目名称:mturk-semantics,代码行数:37,代码来源:init-ai2.scala


示例10: level

//设置package包名称以及导入依赖的类
package x7c1.wheat.splicer.core.logger

import ch.qos.logback.classic.spi.ILoggingEvent
import ch.qos.logback.classic.{Level, LoggerContext}
import ch.qos.logback.core.util.ContextUtil
import ch.qos.logback.{classic, core}
import org.slf4j
import x7c1.wheat.splicer.core.logger.Tap.implicits.Provider


trait LoggerFactory {

  val context: LoggerContext =
    slf4j.LoggerFactory.getILoggerFactory.asInstanceOf[LoggerContext] tap { x =>
      val util = new ContextUtil(x)
      val add = util.addFrameworkPackage(x.getFrameworkPackages, _: String)
      (frameworkPackages :+ getClass.getPackage.getName) foreach add
    }

  val appenderFactories: Seq[Appender.Factory]

  lazy val appenders: Seq[core.Appender[ILoggingEvent]] = {
    appenderFactories.map(_ (context))
  }

  def level: Level

  def frameworkPackages: Seq[String] = Seq()

  def apply[X](klass: Class[X]): slf4j.Logger = {
    slf4j.LoggerFactory.getLogger(klass).asInstanceOf[classic.Logger].tap(
      appenders foreach _.addAppender,
      _ setLevel level,
      _ setAdditive false
    )
  }

}

object Appender {

  type Factory = LoggerContext => core.Appender[ILoggingEvent]

  type From[X] = X => Factory

  def from[X: From](x: X): Factory = {
    implicitly[From[X]] apply x
  }
} 
开发者ID:x7c1,项目名称:Wheat,代码行数:50,代码来源:LoggerFactory.scala



注:本文中的ch.qos.logback.classic.LoggerContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala GlobalTempViewManager类代码示例发布时间:2022-05-23
下一篇:
Scala Authorization类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap