Hi all,
I want to keep track in the logs as well as time message level etc, I want to log down the clients ip address
Is this possible
Thanks,
Rob
Hi all,
I want to keep track in the logs as well as time message level etc, I want to log down the clients ip address
Is this possible
Thanks,
Rob
The server software for each service being run knows which IPs are being served. I’m not familiar with loguru, but if it’s not the web server, I doubt it has the IPs unless something else logs them via it.
when you say server software, you dont mean python or the loguru package, you mean the machine im running python on, if so its a windows 11 pc?
ie when i run the software and in console i get the ip address of the pc accessing the web server
127.0.0.1 - - [21/Jul/2024 20:40:11] "POST /password HTTP/1.1" 200 -
obviously im accessing the web server from the same host but i do get different ips when i try to access the webserver from another LAN pc
worked it out
@app.route('/password', methods=['GET', 'POST'])
def password():
ip_addr = request.remote_addr
form = PasswordForm()
if request.method == 'POST' and form.validate():
logger.warning(f'{ip_addr} {form.un.data} your current password is wrong, please click back and try again')
and in log file i get this
2024-07-22-12-55-27 | WARNING | 127.0.0.1 robert.wild your current password is wrong, please click back and try again