In the BAE platform, there is a way to query the temporary log in container, which is designed to make it easy for users to quickly query the latest logs and understand the container status. But this kind of log do not want to go log service, because the log service is too heavy, real-time relatively poor, but also to change their own code. For these requirements, BAE provides a temporary solution-a local log. This kind of log does not guarantee the storage time, along with the container migration and the recovery, will cause the log to lose, therefore this kind of log's localization is the temporary, does not have the service guarantee, fast and timely one kind of solution.
How the log is printed
Log printing is very simple, using the language provided by the log module, the following example of Python
#-*-coding:utf-8-*-
import os
import sys
import logging
import logging.config
CWD = Os.path.dirname (__file__)
def app (environ, start_response):
status = ' OK '
headers = [(' Content-type ', ' text/html ')]
start_response (status, headers)
logging.config.fileConfig ("/home/bae/app/logging.conf")
Logging.info ("This is a test message")
return "Logging ..." from
bae.core.wsgi import wsgiapplication< C15/>application = wsgiapplication (APP)
Where the logging.conf file is placed under the root directory, as follows
[Loggers]
Keys = root
[handlers]
keys=rotatefilehandler
[formatters]
keys=simpleformatter
[formatter_ Simpleformatter]
format = [% (asctime) s] (% (levelname) s)% (name) s:% (message) s]
[logger_root]
Level=info
Handlers=rotatefilehandler
[Handler_rotatefilehandler]
Class=handlers. Rotatingfilehandler
level=info
formatter=simpleformatter
args= ("/home/bae/log/user.log", ' a ', 20971520, 5)
Cleanup of logs
BAE at intervals will clean up the user's log, mainly has the following several policy log access path, unified storage under/home/bae/log, do not establish self-folder and soft connection log segmentation, log slicing by the user's own designation, BAE View log is located by prefix name, suffix name customization way
Like what
User.log.1
User.log.2
is considered the same log [user], viewing the log will always see the latest
But
User1.log
User2.log will be considered as two kinds of logs [User1, User2]
2. Limit
Each major class of log limit is 100M, the user's total log size limit is 250M, exceeding the limit will be in the background to clean up periodically
The deletion of the policy is generally to delete the oldest log, according to the Linux modify time to determine
FAQ 1. This will be the final form of Bae V3 logs.
Of course not.
There are two types of logs, 1) Debug, which mainly solves the error view during application development and deployment, does not need long-term saving 2) long-term storage, need long-term preservation, the future may be used as analysis, the integrity of the log requirements higher.
The goal of the local log is for immediate debugging, and Bae follows up with a powerful, multi-distributed log. 2. Why are there so many restrictions
Local log, as the name implies is the existence of the log on the machine, the physical machine disk is limited, it is impossible to open a large space for a single user, and we think that 250M is enough users to do debugging.
As for why user segmentation, this is due to different user suffixes using different habits. And in Linux, forced MV dropped files, some without the reopen mechanism of the log library, unable to properly handle the MV event. And the MV Walk will cause the loss of some logs. 3. Why is it not supported to query by time period
Because the local log is not a schema, that is, BAE does not make any assumptions about the user log format, so there is no way to confirm a single log point in time, so the time period query 4 is not supported . Why don't support keyword queries
Keyword query If you do not index, the reason is similar to 3, the future users can download, local query. Distributed log queries can be a lot more powerful 5. I can't see the server log.
This is because the previous application of the container, the log did not hit the designated directory, the new application of the container have been able to
Also, make sure that the log print directory is
/home/bae/log
http://godbae.duapp.com/?p=313