async-worker / aiologger

Asynchronous logging for Python and asyncio
https://async-worker.github.io/aiologger/
MIT License
129 stars 13 forks source link

Where an aio-logger output at systemd? #3

Open leichgardt opened 3 years ago

leichgardt commented 3 years ago

I'm trying to use aiologger in my service but I don't see the output of AsyncStreamHandler into $ journalctl -u my.service. When I was running my project $ python main.py of course I could see the logger output.

What do I need to do for journalctl aio-logging?

system: ubuntu 20.04 python: 3.8

meskio commented 1 year ago

I'm having problems also with aiologger and journald. Using a simple example:

import asyncio
from aiologger import Logger

async def main():
    logger = Logger.with_default_handlers(name='my-logger')

    count=0
    while count<10:
        await logger.info(f"{count}")
        count+=1

    await logger.shutdown()

loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()

And run it with systemd:

systemd-run ./log.py

I see the first 0, but the rest of attempts to log give an error:

pipe closed by peer or os.write(pipe, data) raised exception.

The application I'm working on freezees when calling the logger. But I didn't manage to produce a simple example to reproduce it.

Can it be related to #4.