Hello,
I just starting using LogzIO (cause I saw the package on the installed list and I wanted to integrate a more robust monitoring solution.)
I am using the python logger, with the LogzIO Handler with a dictConfig().
When I log messages at the module level, they ship to LogzIO without issue. However, when I log from inside an @anvil.server.http_endpoint
function or an @anvil.server.callable
function, the log messages show up in the Anvil App log but don’t get shipped to LogzIO.
Is it possible the code in the annotation is interfering with LogzIO log handler ?
Related code:
Log Config Dict:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'local': {
'format': '%(asctime)s %(message)s',
},
'simple': {
'format': '%(asctime)-15s %(name)-15s %(levelname)-8s: %(message)s'
},
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
},
'logzioFormat': {
'format': '{"additional_field": "value"}'
}
},
'handlers': {
'console1': {
'class': 'logging.StreamHandler',
'formatter': 'simple',
'stream': 'ext://sys.stdout',
'level': 'DEBUG'
},
'console2': {
'class': 'logging.StreamHandler',
'formatter': 'local',
'stream': 'ext://sys.stdout'
},
'logzio': {
'class': 'logzio.handler.LogzioHandler',
'level': 'INFO',
'formatter': 'logzioFormat',
'token': ' {{fill_with_real_token}}',
'url': 'https://listener.logz.io:8071'
}
},
'loggers': {
'': { # Root Logger
'level': 'DEBUG',
'handlers': ['console1', 'logzio'],
'propogate': True
}
}
}
Server Code Snippets:
logging.config.dictConfig(LOGGING)
root = logging.getLogger()
logger = root
logger.info('APIServerModule INFO Sniff Test ')
logger.warn('APIServerModule WARN Sniff Test ')
logger.error('APIServerModule ERROR Sniff Test ')
logger.exception('APIServerModuleEXCEPTION Sniff Test')
@anvil.server.http_endpoint('/add/:a/:b')
def add_numbers(a, b):
logger.info("ENTERING: add_numbers")
a = int(a)
b = int(b)
return {
'originals': [a, b],
'sum': a + b,
}
Recap
When the above code runs, the 4 “Sniff Test” log messages appear in Anvil App Logs AND LogzIO.
However when add_numbers
is called (via PostMan, Curl, etc), the ENTERING add_numbers
log message only shows up Anvil App Logs, it never appears in LogzIO.
Based on the fact the module level logging works as expected, I am deducing that the issue is
- (a) In the LogzIO Handler …
- (b) Something with the Anvil annotation altering the log config or squashing the network IO or otherwise interfering so Handler cannot execute as expected
Any thoughts ? or suggestion how I might further investigate and resolve this issue ?
Thanks in advance.
Cheers,
Tyler
More Data
Screen Shot of Anvil Logs
with my API token obscured. But you can see the APIServerModule Sniff Tes Log and the add_numbers
(last entry)
However, in LogzIO … “Sniff Test” messages make it, but the add_numbers
did not.