Question: I want to log exceptions with the following code, but I get a 500 error. If I omit `%s` and `someGlobalVariable`, it doesn't return an error. Why isn't this working?

```
except Exception as e:
    logging.warning(("%s Exception::Login:: "+ str(e.args)), % (someGlobalVariable))  
    return False

```

Answer: 
Your syntax is wrong `, %` is not valid because `%` is a binary op. You don't use the `% (value)` syntax when letting `logging` do the substitution. Pass the values as further arguments to the logging method.

```
logging.warning('%s Exception::Login:: %s', someGlobalVariable, str(e.args))

```
You have a syntax error there in the substitution of `someGlobalVariable`, should be:

```
logging.warning('%s Exception::Login:: %s' % (someGlobalVariable, str(e.args)))

```

As @davidism said on his answer (and comment below), letting the logger make the substitution itself is more efficient, since you can avoid string substitution:

```
logging.warning('%s Exception::Login:: %s' , someGlobalVariable, str(e.args))

```