【发布时间】:2019-05-02 13:51:34
【问题描述】:
我刚刚开始使用 Docker。
我正在处理由另一位开发人员编写的项目。在项目Docker容器中,我有三个微服务(aggregatore、classificatore、testmicro),每个都使用python模块logging进行调试。
我的问题是我不知道在哪里可以查看logging 输出。
docker-compose.yml
version: '2.1'
services:
files:
image: busybox
volumes:
[..]
grafana:
[..]
prometheus:
[..]
aggregatore:
[..]
classificatore:
build: classificatore/.
volumes:
- [..]
volumes_from:
- files
ports:
- [..]
command: ["python", "/src/main.py"]
depends_on:
rabbit:
condition: service_healthy
testmicro:
[..]
rabbit:
[..]
我是终端,我运行
$docker-compose up -d
这会启动所有微服务。
让我们专注于分类服务。
分类器/Dockerfile
FROM python:3
RUN mkdir /src
ADD requirements.txt /src/.
WORKDIR /src
RUN pip install -r requirements.txt
ADD . /src/.
RUN mkdir -p /tmp/reqdoc
CMD ["python", "main.py"]
classificatore/main.py
import logging
logging.basicConfig(format='%(asctime)s %(message)s', level=logging.DEBUG)
logging.getLogger('pika').setLevel(logging.WARNING)
log = logging.getLogger()
[..]
app = Flask( __name__ , template_folder='./web')
@app.route("/")
def index(message=None):
log.info("classificatore index!! ")
[..]
return render_template('index.html', files1=files1, files2=files2, message=message)
在上面的代码中,输出文本“classificatore index”去哪里了?
感谢您提供的任何支持。
【问题讨论】:
标签: python docker docker-compose python-logging