-
|
I code app = Application(__name__)
from logging.handlers import RotatingFileHandler
handler = RotatingFileHandler("app.log", maxBytes=10240, backupCount=3)
app.logger.addHandler(handler)then @app.route('/')
async def index(request, **server):
session = request.ctx.session
logger = server['logger']
logger.info('Current page: /')
if session is None or not session.is_logged_in():
return b'You are not logged in. <a href="/login">Login</a>.'
return b'Welcome to Dashboard. <a href="/logout">Logout</a>.'the logging just print on console, not in 'app.log'('app.log' file created,but still blank) |
Beta Was this translation helpful? Give feedback.
Answered by
nggit
Dec 4, 2025
Replies: 1 comment 2 replies
-
|
The logger handler behaviour is not reliably inherited to child process. When you do it in main. Especially when using spawn / Windows? What if you do it inside @app.on_worker_start
async def worker_start(app):
handler = RotatingFileHandler("app.log", maxBytes=10240, backupCount=3)
app.logger.addHandler(handler)
@app.route('/')
async def index(request, logger, **server):
session = request.ctx.session
logger.info('Current page: /') |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
ockan
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The logger handler behaviour is not reliably inherited to child process. When you do it in main. Especially when using spawn / Windows?
What if you do it inside
@app.on_worker_start?