python - 如何在 Apache/Flask 中将多行字符串记录为单个日志条目?
问题描述
我有一个使用 apache 部署的烧瓶应用程序。我正在尝试将格式良好的异常堆栈跟踪打印到错误日志中,但是每一行文本都作为单独的条目日志打印在 apache 的错误日志中,这使得堆栈跟踪难以阅读。
作为一个最小的例子,我在烧瓶路线中有以下语句:
print('hello\nworld')
错误日志的实际输出是:
[Sat Jun 19 12:39:41.143577 2021] [wsgi:error] [pid 31837:tid 139869910443776] [
remote 90.64.164.4:34160] hello
[Sat Jun 19 12:39:41.143580 2021] [wsgi:error] [pid 31837:tid 139869910443776] [
remote 90.64.164.4:34160] world
[Sat Jun 19 12:39:41.143583 2021] [wsgi:error] [pid 31837:tid 139869910443776] [
remote 90.64.164.4:34160]
I would like it to be part of one entry like this:
[Sat Jun 19 12:39:41.143583 2021] [wsgi:error] [pid 31837:tid 139869910443776] [
remote 90.64.164.4:34160] hello
world
否则,我将不胜感激有关使用 apache 将堆栈跟踪写入日志文件的提示。
解决方案
推荐阅读
- javascript - JavaScript 中的日期和时间格式
- javascript - 为什么 ngIf 会破坏其中组件的功能?我应该如何处理这种情况?
- android - 设置 BottomNavigationView + 导航组件的问题
- flutter - Flutter/Dart:子类化冻结的数据类
- android - Android 推送通知机制
- c# - 如何使用 CsvHelper 库读取没有引用的 csv 文件?
- python - 避免嵌套条件
- css - 停止 flex 元素增长超过 max-height:max-content
- assembly - 汇编语言中 10 个数字的平均值
- c# - 更新错误查询(“空路径不合法)