kotlin-logging
3,114
Stars
130
Forks
18
Watchers
5
Open Issues
Apache-2.0
许可证
Kotlin
语言
2016-07-01
创建时间
2026-11-10
最近更新
项目能做什么
轻量级 Kotlin 跨平台日志框架,提供便捷高性能的日志门面。
来源:AI 基于仓库事实生成
· 内容以仓库实际 README 为准
使用说明 查看原始 README 原仓库文档
中文使用说明暂未生成。下面保留原仓库 README 摘录,命令与配置均以原文为准。
原始 README 摘录(英文原文,节选前 3000 字符)
# [kotlin-logging](https://github.com/oshai/kotlin-logging) [](https://github.com/oshai/kotlin-logging/actions/workflows/ci.yml) [](https://kotlinlang.slack.com/messages/kotlin-logging/) [](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22io.github.oshai%22) [](https://github.com/oshai/kotlin-logging/blob/master/LICENSE) [](https://kotlinlang.org/) [](https://github.com/oshai/kotlin-logging) <img width="1024" height="559" alt="image" src="https://github.com/user-attachments/assets/04d2c80d-934d-4d02-a3b2-32ad73cb8542" />
Lightweight Multiplatform logging framework for Kotlin, written in
[](https://kotlinlang.org/).
A convenient and performant logging facade.
#### Call log methods, without checking whether the respective log level is enabled
```Kotlin
logger.debug { "Some $expensive message!" }
```
Behind the scenes the expensive message do not get evaluated if debug is not enabled:
```Kotlin
// This is what happens when you write the above ^^^
if (logger.isDebugEnabled) logger.debug("Some $expensive message!")
```
#### Define the logger, without explicitly specifying the class name
```Kotlin
// Place definition above class declaration to make field static
private val logger = KotlinLogging.logger {}
```
Behind the scenes `val logger` will be created in the class, with the class/file name:
```Kotlin
// This is what happens when you write the above ^^^
val logger = LoggerFactory.getLogger("package.ClassName")
```
#### Log exceptions in a Kotlin-style
```Kotlin
// exception as first parameter with message as lambda
logger.error(exception) { "a $fancy message about the $exception" }
```
#### Fluent logging in a Kotlin-style
```kotlin
logger.atWarn {
message = "foo $bar"
cause = exception
payload = buildMap(capacity = 3) {
put("foo", 1)
put("bar", "x")
put("obj", Pair(2, 3))
}
}
```
## Getting started
```Kotlin
import io.github.oshai.kotlinlogging.KotlinLogging
private val logger = KotlinLogging.logger {}
class FooWithLogging {
val message = "world"
fun bar() {
logger.debug { "hello $message" }
}
}
```
## Download
**Important note:** kotlin-logging depends on slf4j-api (in the JVM artifact). In runtime, it is also required to depend on a logging implementation. More details in [how-to-configure-slf4j](http://saltnlight5.blogspot.co.il/2013/08/how-to-configure-slf4j-with-different.html). And an excellent det
阅读完整原文
商业机会分析 AI 生成
Kotlin 专用日志增强与敏感数据脱敏 Gradle/Compiler 插件 (SaaS/On-Premise 授权)
| 产品构想 | 利用 Kotlin 编译器插件(K2/IR)或字节码插桩,针对 kotlin-logging 的 Fluent API 和 Lambda 日志进行编译期静态分析、敏感字段自动脱敏、无用日志去除(优化生产包体积)以及结构化参数自动提取。 |
| 核心功能 | 编译期日志脱敏与语法检查、动态日志级别远程控制插桩、生产构建剥离特定等级日志、日志格式标准化静态校验。 |
| 目标用户 | 中大型金融、电商、医疗等合规要求极高的 Kotlin/Android/JVM 研发团队及架构师。 |
| 难度/周期 | 高 · 3-6个月 · 成本:开发机器、多版本 Kotlin 编译器适配测试集群成本、销售与合规验证成本。 |
| 收费模式 | 企业授权许可(按应用/开发者席位年费付费)、支持定制规则与报告服务。 |
| 竞争风险 | Kotlin 编译器 API(K2)变更频繁导致维护成本高;企业对第三方编译插件有安全顾虑。 |
| 依据 | 已验证事实 |
KMP 跨平台全栈统一日志与可观测性 SDK/后端(开箱即用套件)
| 产品构想 | 结合 kotlin-logging 的 multiplatform facade 特性,封装适配 iOS、Android、Desktop、Web 的轻量级本地日志滚动存储与远程上报引擎,提供即插即用的轻量收集后台/开发调试 Dashboard。 |
| 核心功能 | 支持 iOS/Android/JVM 的统一日志落盘与加密上传、本地离线日志打包导出、网络状态自适应上报、简易日志排查 Web 后台。 |
| 目标用户 | 采用 Kotlin Multiplatform 技术栈的中小型移动端或全栈开发团队。 |
| 难度/周期 | 中等 · 2-4个月 · 成本:云端多租户服务架构成本、日志存储与网络带宽开销。 |
| 收费模式 | 免费额度 + 按上报日志量计费的 SaaS 订阅,或私有化部署一键包买断。 |
| 竞争风险 | 市场上有成熟的 Datadog、Sentry 等巨头 APM 方案,直接竞争压力大。 |
| 依据 | 尚需验证的假设 |
IntelliJ IDEA / Android Studio 日志分析与规范辅助商业插件
| 产品构想 | 为 JetBrains IDE 提供围绕 kotlin-logging 的高效开发工具,包括动态生成最佳实践日志模板、性能反模式告警(如非延迟评估误用)、实时日志语法高亮、内联结构化日志快速排查等功能。 |
| 核心功能 | 日志代码异味检测(如缺少上下文、未使用 Lambda)、代码重构建议、IDE 内与后端日志关联快速跳转、团队日志格式统一模板分发。 |
| 目标用户 | 追求高开发规范与效率的 Kotlin 工程师及技术团队。 |
| 难度/周期 | 中等 · 1-2个月 · 成本:JetBrains Marketplace 开发者账号注册费用及维护精力。 |
| 收费模式 | JetBrains Marketplace 付费订阅制(Freemium,高级静态检查与团队配置功能收费)。 |
| 竞争风险 | 用户付费意愿偏弱(偏好免费内置 Inspect 规则);产品体量偏小,变现天花板有限。 |
| 依据 | AI推测 |
AI 基于仓库公开数据分析生成,含推测成分,不构成收益承诺。
报告会保存到 个人中心
竞品与相似项目 GitHub Search 真实检索
| 项目 | 中文简介 | Stars | 语言 |
|---|---|---|---|
| morluto/rea | 中文介绍暂未生成 Reverse engineer anything with agents, from app behavior dow |
452,047 | TypeScript |
| flutter/flutter | 中文介绍暂未生成 Flutter makes it easy and fast to build beautiful apps for m |
181,180 | Dart |
| Genymobile/scrcpy | 中文介绍暂未生成 Display and control your Android device |
154,568 | C |
| rustdesk/rustdesk | 中文介绍暂未生成 An open-source remote desktop application designed for self- |
129,036 | Rust |
| react/react-native | 中文介绍暂未生成 A framework for building native applications using React |
126,898 | C++ |
| Hack-with-Github/Awesome-Hacking | 中文介绍暂未生成 A collection of various awesome lists for hackers, pentester |
125,257 | - |
以上为通过 GitHub 官方 Search API 检索的相似项目,功能差异与优劣势需进一步人工确认,配置 AI 后可生成对比分析。
项目优势与风险
| 技术成熟度 | 创建于 2016-07-01,近 30 天仍在推送,发布过 100 个 Release |
| 社区活跃 | Star 3,114 / Fork 130 / Issue 5(数据支持,可自行核实) |
| 许可证 | Apache-2.0 |
| 主要风险 | 上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价 |
安装与使用
快速开始(以仓库 README 为准)
git clone https://github.com/oshai/kotlin-logging.git cd kotlin-logging # 请阅读仓库 README 获取确切安装步骤(依赖、配置、启动命令)
术语说明:Docker=应用容器(把程序和依赖打包运行);API Key=调用外部服务的密钥;Git Clone=把仓库代码下载到本地。常见错误:API Key 未配置 / 端口占用 / 数据库连接失败,多数项目在 README 的 Troubleshooting 章节有说明。