Anvil App Server 1.13.2 stdout no longer prints to the log

What I’m trying to do:
Prior to upgrading to 1.13.2 (we were on 1.10.1) we set up our logging to stdout, which added our messages to the log. Since upgrading to 1.13.2, we are not seeing any of these messages making it to the log

What I’ve tried and what’s not working:
Below is an example of what worked previously, but no longer does:
Code Sample:
In a server module:

import logging
logger = logging.getLogger('server')
handler = logging.StreamHandler(sys.stdout)
logger.addHandler(handler)

formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(filename)s: %(message)s')
handler.setFormatter(formatter)

@anvil.server.callable(require_user=True)
def log_warning(message):
  """Only callable from the server code"""
  if logger.isEnabledFor(logging.WARNING):
    sanitized_message = sanitize_log_message(message)
    logger.warning(get_log_tag() + sanitized_message)

The app server is started like this:

anvil-app-server --config-file app_config.yaml >> /deploy/application/logs/frontend.log 2>&1 &

Previously, this would log information out to the frontend.log, but it no longer does. I presume that logging changed since 1.10.1

Is there a way to have our logging included in the general output (because the logs that anvil produces are valuable, and we’d like them all in the same place)?

2 Likes

If this is no longer possible, can we somehow add timestamps to the anvil logging? That way we could look across logs and see what is going on.

2 Likes

I second this emotion!!

3 Likes

Just a note for those using the open source anvil-app-server:
In the data directory (by default .anvil-data) there is a file called error.log that does include a timestamp.

2 Likes

Hi @mapgar,

This wasn’t a deliberate change - we’re looking into it!

2 Likes

Any update on this? We need to know if we need to change our logging approach.

Have you seen

?

2 Likes

I definitely did not. Thanks!

1 Like