Appdaemon keeps crashing when adding user defined log files

I’m really happy to start using Appdaemon for automation. Now I’m starting to have a couple of apps running and and would like to separate the logs from groups of apps to simplify for myself.

I started with adding user defined log named avfuktare_log in appdaemon.yaml (I removed the beginning of the file):

logs:
  error_log:
    filename: /config/appdaemon/logs/error.log
  main_log:
    filename: /config/appdaemon/logs/appdaemon.log
  access_log:
    filename: /config/appdaemon/logs/access.log
  diag_log:
    filename: /config/appdaemon/logs/diag.log
  avfuktare_log:
    filename: /config/appdaemon/logs/avfuktare.log

After restart of Appdaemon in HA I get cyclic restarts of Appdaemon and the log shows a couple of things:

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
cont-init: info: running /etc/cont-init.d/00-banner.sh
-----------------------------------------------------------
 Add-on: AppDaemon
 Python Apps and Dashboard using AppDaemon 4.x for Home Assistant
-----------------------------------------------------------
 Add-on version: 0.9.3
 You are running the latest version of this add-on.
 System: Home Assistant OS 9.3  (aarch64 / odroid-n2)
 Home Assistant Core: 2022.10.5
 Home Assistant Supervisor: 2022.10.0
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
cont-init: info: /etc/cont-init.d/00-banner.sh exited 0
cont-init: info: running /etc/cont-init.d/01-log-level.sh
cont-init: info: /etc/cont-init.d/01-log-level.sh exited 0
cont-init: info: running /etc/cont-init.d/appdaemon.sh
Looking in links: https://wheels.home-assistant.io/musllinux/
Collecting mysql.connector
  Downloading mysql-connector-2.2.9.tar.gz (11.9 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 11.9/11.9 MB 25.8 MB/s eta 0:00:00
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Building wheels for collected packages: mysql.connector
  Building wheel for mysql.connector (setup.py): started
  Building wheel for mysql.connector (setup.py): finished with status 'done'
  Created wheel for mysql.connector: filename=mysql_connector-2.2.9-cp310-cp310-linux_aarch64.whl size=247968 sha256=f9e44e619065ee4aa93bf3a3f7826d197e1051b5c7660ff00b74d381b3147b8e
  Stored in directory: /tmp/pip-ephem-wheel-cache-c2p74mp0/wheels/76/48/9b/da67ff1a18fe8e9d428f9b1a177716d4a7d363d2bbe83bf6cf
Successfully built mysql.connector
Installing collected packages: mysql.connector
Successfully installed mysql.connector-2.2.9
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
cont-init: info: /etc/cont-init.d/appdaemon.sh exited 0
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
services-up: info: copying legacy longrun appdaemon (no readiness notification)
s6-rc: info: service legacy-services successfully started
[09:57:13] INFO: Starting AppDaemon...
Traceback (most recent call last):
  File "/usr/bin/appdaemon", line 8, in <module>
    sys.exit(main())
  File "/usr/lib/python3.10/site-packages/appdaemon/__main__.py", line 443, in main
    admain.main()
  File "/usr/lib/python3.10/site-packages/appdaemon/__main__.py", line 387, in main
    self.logging = logging.Logging(logs, args.debug)
  File "/usr/lib/python3.10/site-packages/appdaemon/logging.py", line 274, in __init__
    logger = logging.getLogger(args["name"])
KeyError: 'name'
[09:57:18] WARNING: AppDaemon crashed, halting add-on
s6-rc: info: service legacy-services: stopping

There is obviously an error with the name of the logger. I have done what I thought should done according to the logging documentation for Appdaemon.

I also see that mysql.connector is downloaded every time Appdaemon is restarted. Is this normal?

Main problem is the user defined logging. What is I doing wrong?

Edit: If I remove the last two rows in appdaemon.yaml there is no crash any longer so I’m pretty sure something is wrong with those rows.

Edit 2: I realized that it was me who added the need for mysql.connector in a test app. I still have the crash of Appdaemon due to adding a user defined log file.

See here: Configuration — AppDaemon 4.2.1 documentation

All custom log files must have a name entry, so try:


  avfuktare_log:
    name: name_of_your_log
    filename: /config/appdaemon/logs/avfuktare.log
2 Likes

Thanks a lot!

When I look into the Appdaemon configuration part about the log configuration the name directive is not mentioned as one of the directives. It is however mentioned in the text which I missed.

I will read more carefully the next time.

1 Like

And the name directive is missing an explanation. ¯_(ツ)_/¯