There are two errors in that section of code.
First, you are missing a closing parenthesis:
logging.basicConfig(filename=file_log, level=logging.DEBUG, format ='%(message)'
# ----^ -------^
Without that closing parenthesis, Python does not know when that expression is supposed to end. The next line then doesn't make sense and raises a SyntaxError
exception.
Your next line has a stray colon:
chr(event.Ascii):
which you need to remove. You also do not store the result of that call, you could just omit that line.
The following is correct Python.
def OnKeyboardEvent (event):
logging.basicConfig(filename=file_log, level=logging.DEBUG, format ='%(message)')
logging.log(10, chr(event.Ascii))
return True