日志未保存到Docker环境中的文件 [英] Log doesn't save to file in docker environment

查看:152
本文介绍了日志未保存到Docker环境中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的生产环境production.rb中.我已经配置了我的日志,将其保存到文件中:

In my production environment production.rb. I have configured my log will be saved to file:

  config.logger = Logger.new('log/production.log')

当我在本地运行时(通过使用命令行rails s -e production启动服务器).一切正常.但是当我在docker环境中运行时,我看不到production.log打印出来.

When I run locally (start server by using command line rails s -e production). everything works fine. But when I run on docker environment, I don't see production.log printed out.

请帮助我解决这个问题.

Please help me about this problem.

推荐答案

我看不到production.log打印出来.

I don't see production.log printed out.

您要去哪里?在主机上还是正在运行的Docker容器中?

Where are you looking? On your host or in the docker container that you are running?

默认情况下,该文件将在您的容器文件系统中创建.
如果您希望它从您的主机(运行docker守护程序)直接可见,则需要首先将主机目录作为数据卷安装.

By default, the file will be created in your container filesystem.
If you want it directly visible from your host (which runs the docker daemon), you would need to mount an host directory as a data volume first.

docker run -d -P --name myapp -v /a/local/host/path:/path/to/log/in/container myimage

然后您会在/a/local/host/path中看到production.log.

这篇关于日志未保存到Docker环境中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆