
python-3.5.5
Flask
sap_cf_logging
from flask import Flask, request
from sap.cf_logging import flask_logging
import os, logging
app = Flask(__name__)
#Iitialize logging
flask_logging.init(app, logging.INFO)
cf_port = os.getenv('PORT')
# Only get method by default
@app.route('/')
def hello():
logger = logging.getLogger('my.logger')
logger.info(request)
print(request)
return 'Hello World'
if __name__ == '__main__':
if cf_port is None:
app.run(host='0.0.0.0', port=5000, debug=True)
else:
app.run(host='0.0.0.0', port=int(cf_port), debug=True)
cf push <application name>
cf logs <application name>
cf logs <application name> --recent
{
"msg": "<Request 'http://sample-logging-proud-impala.cfapps.eu10.hana.ondemand.com/' [GET]>",
"line_no": 16,
"layer": "python",
"written_ts": 1544603923048154000,
"correlation_id": "74f6ee3d-433d-4797-467d-cae1f053812b",
"component_name": "sample-logging",
"space_name": "dev",
"logger": "my.logger",
"container_id": "10.0.137.233",
"thread": "Thread-12",
"written_at": "2018-12-12T08:38:43.048Z",
"level": "INFO",
"component_instance": "0",
"type": "log",
"space_id": "2741076c-c551-4b62-8ebc-c1328bbc08d7",
"component_id": "1df97d1e-6386-48b7-9035-3bab082edffc",
"component_type": "application"
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
13 | |
12 | |
11 | |
10 | |
10 | |
9 | |
8 | |
8 | |
8 | |
7 |