- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
Heroku 在其 Twelve-Factor App manifest 中描述了日志作为简单的事件流:
Logs are the stream of aggregated, time-ordered events collected from the output streams of all running processes and backing services. Logs in their raw form are typically a text format with one event per line (though backtraces from exceptions may span multiple lines). Logs have no fixed beginning or end, but flow continuously as long as the app is operating.
stdout
,将任务留给“环境”。
A twelve-factor app never concerns itself with routing or storage of its output stream. It should not attempt to write to or manage logfiles. Instead, each running process writes its event stream, unbuffered, to stdout. During local development, the developer will view this stream in the foreground of their terminal to observe the app’s behavior.
In staging or production deploys, each process’ stream will be captured by the execution environment, collated together with all other streams from the app, and routed to one or more final destinations for viewing and long-term archival. These archival destinations are not visible to or configurable by the app, and instead are completely managed by the execution environment. Open-source log routers (such as Logplex and Fluent) are available for this purpose.
docker logs
) 是否安全? stdout
被直接重定向到一个文件(磁盘空间)? docker run --volume=[]
)中? 最佳答案
Docker 1.6 introduced logging drivers的概念提供对日志输出的更多控制。 --log-driver
标志配置在哪里 stdout
& stderr
从在容器中运行的进程应该被引导。另见 Configuring Logging drivers .
有几个驱动程序可用。请注意,除了 json-file
之外的所有这些禁止使用 docker logs
收集容器日志。
/var/lib/docker/containers/<containerid>/<containerid>-json.log
中可用--log-opt
通过 TCP、UDP 或 Unix 域套接字将日志消息定向到指定的系统日志。同时禁用 docker logs
docker run --log-driver=syslog --log-opt syslog-address=tcp://10.0.0.10:1514 ...
stdout
&
stderr
.但是,某些软件不会将日志消息写入
stdout/stderr
.例如,它们改为写入日志文件或系统日志。在这些情况下,下面原始答案中的一些细节仍然适用。回顾一下:
/dev/log
将主机的系统日志套接字( -v /dev/log:/dev/log
)挂载到容器,发送到主机的系统日志. Is it safe to rely on Docker's own log facility (docker logs)?
docker logs
每次都打印整个流,而不仅仅是新日志,所以不合适。
docker logs --follow
会给
tail -f
- 类似的功能,但是你有一个 docker CLI 命令一直在运行。因此虽然运行
docker logs
是安全的,不是最优的。
Is it safe to run docker undetached and consider its output as the logging stream?
Can stdout be redirected to a file directly (disk space)?
docker run ... > logfile
做到这一点当然,但是自动化和管理感觉很脆弱和更难。
If using a file, should it be inside the docker image or a bound volume (docker run --volume=[])?
Is logrotation required?
/var/lib/docker/devicemapper/mnt/<containerid>/rootfs/...
.需要一些丑陋的包装器才能让 logrotate 找到该路径下的日志。
Is it safe to redirect stdout directly into a logshipper (and which logshipper)?
Is a named pipe (aka FIFO) an option?
docker logs
.
/var/lib/docker/containers/<containerid>/<containerid>-json.log
.
关于logging - 如何使用 docker 在微服务架构中发送日志?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24807557/
不同的 LogCat 方法是: Log.v(); // Verbose Log.d(); // Debug Log.i(); // Info Log.w(); // Warning Log.e();
在android群里,经常会有人问我,android log是怎么用的,今天我就把从网上以及sdk里东拼西凑过来,让大家先一睹为快,希望对大家入门android log有一定的帮助. android
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭 4 年前。 社区 12
我正在尝试使用 sonarlint 检查代码质量.上面的问题概要,我不明白为什么它要说要大写。但是 this discussion与上述建议相反。哪一个应该被认为是正确的? 最佳答案 这没有正确答案,
随着 n 变大,log*(log n) 和 log(log* n) 这两个函数会更快吗? 这里,log* 函数是迭代对数,定义如下: 我怀疑它们是相同的,只是写法不同,但它们之间有什么区别吗? 最佳答
作为家庭作业,我被要求在 O(log(n)) 中编写一个算法,我可以计算出我编写的算法的复杂度为 O(log(n) + log(n/2) + log(n/4) + log(n/8) + ... + l
我正在使用 Tomee。日志文件夹包含这样的文件 localhost_access_log.2016-12-02.txt localhost.2016-12-02.log catalina.2016-
Android Log.v、Log.d、Log.i、Log.e 等的 ios 等效项是什么?同样在 android 上,我使用 Android 设备监视器和 logcat 来访问我的手机日志,我需要在
我认为下面的代码是 O(log log n) 因为它里面有 i*i 但我对 log n 感到困惑> 和 log (log n)。 for (i=2; i*i<=number; i++) { if
我正在修改 kvm 模块,并在内核代码中添加了 printk 语句。运行虚拟机后,printk 为我提供了错误地址和有关 guest 操作系统的其他信息。 我需要从这个信息中生成统计信息。当我使用 d
我有一个部署为 Windows Azure Web 角色的 WCF 服务。 我正在使用 Enterprise Library 进行异常处理,并且在我的本地 Development Fabric 中,似
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭 9 年前。 Improv
在 Go 的生产中使用 log.SetFlags(log.LstdFlags | log.Lshortfile) 是好的做法(至少是一般做法)吗?我想知道在生产中这样做是否存在性能或安全问题。因为它不
我想知道什么更快: double value = Math.log(a) - Math.log(b); 或 double value = Math.log(a/b); 我计算值的方式是否会对性能产生影
我有数百个子例程使用 log.Println() 写入日志文件 我正在使用 log.Println 写入 error.log 文件。 func main() { e, err := os.Open
我将 Nuxt 与 SSR 一起使用,并希望有类似于 apaches 的 access.log 和 error.log 的东西 我特别感兴趣的是每次调用的响应时间。 我在 nuxt 文档中找不到任何内
我知道以前有人问过这个问题,但我相信这是一个不同的问题。 Nginx 在 www-data 下运行: $ ps -eo "%U %G %a" | grep nginx root root
我在我的日志文件中发现了一个非常奇怪的条目 Jan 29 01:35:30 vs-proj-handy sshd[5316]: Received disconnect from 130.207.203
对于我正在开发的应用程序,我希望在开发过程中和发布时简化故障排除。我希望能够检索到对 Log 的调用,以了解在 USB 调试中没有连接手机的情况下运行应用程序时的调用,以便可以检索并发送给我。例如,当
我试图捕获 panic 并记录错误: func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloRep
我是一名优秀的程序员,十分优秀!