Anonymize client IP addresses in Joomla log files - how?

Need help with the Administration of your Joomla! 3.x site? This is the spot for you.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
gba
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 117
Joined: Tue Jun 03, 2014 3:37 pm

Anonymize client IP addresses in Joomla log files - how?

Post by gba » Mon Jul 05, 2021 10:27 am

Hello!

How can I make Joomla replace the last 2 digits of the IP addresses logged in the Joomla log files with *?
i. e. error.php, joomla_update.php

Kind regards,
Gerald

gba
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 117
Joined: Tue Jun 03, 2014 3:37 pm

Re: Anonymize client IP addresses in Joomla log files - how?

Post by gba » Wed Jul 07, 2021 9:23 am

Hi again!

@Development team:
As this is a serious matter concerning GDPR I'd be grateful for your feedback to my inquiry.
Thank you very much in advance!

Kind regards,
Gerald

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 24985
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, Netherlands
Contact:

Re: Anonymize client IP addresses in Joomla log files - how?

Post by pe7er » Wed Jul 07, 2021 3:16 pm

gba wrote:
Wed Jul 07, 2021 9:23 am
As this is a serious matter concerning GDPR I'd be grateful for your feedback to my inquiry.
Thank you for your concern! Privacy is IMHO a very important subject and complying with the GDPR too.

However I don't think that this is a GDPR or privacy issue.
IMHO you don't need a technical solution. Just document it in your Processing Index and in your website's privacy statement.

The Processing Index is documentation for the Privacy Authorities about your processing activities: details of the controller ( = responsible person), data categories, the purpose of the data processing, legal justification, categories of recipients (with who do you share the data), deleting deadline, security measures to safeguard that data).

Legitimate interest of the controller
  • To me collecting IP addresses that cause errors (by default logged in administrator/logs/error.php) on your website seems like a legitimate interest of the controller: As website owner you need to be able to find the cause of errors and solve them.
  • The update logs (by default logged in administrator/logs/joomla_update.php) don't record visitor's IP addresses but only the name + IP address of the super administrator who did the update.
When you add this info to your Processing Index and privacy statement, you should also add that your web server (Apache, Nginx, etc) also keeps visitors IP addresses in its server logs by default. But maybe you've chosen to disable that. Those server access- and error log files are temporary kept on the server for solving errors or safety (register hack attacks and blocking those IPs your server's firewall automatically using fail2ban)

If you don't agree with me, no worries :-)
You can always create an issue about it at: https://github.com/joomla/joomla-cms/issues
If other people agree with you, then maybe we can make the collection of IP address with errors / updates optional.
Kind Regards,
Peter Martin, Global Moderator
Company website: https://db8.nl/en/ - Joomla specialist, Nijmegen, Netherlands
The best website: https://the-best-website.com

gba
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 117
Joined: Tue Jun 03, 2014 3:37 pm

Re: Anonymize client IP addresses in Joomla log files - how?

Post by gba » Thu Jul 08, 2021 9:22 am

Hi!

Thank you very much for taking time for my question!

I do understand your explanation and your point of view.
Actually I indeed have to enable IP address masking in the access_log / error_log on the web servers of some customers.

Due to different requirements by customers, in my opinion Joomla should leave it up to the website admin to choose whether the IP addresses in Joomla's log files are masked or not - ideally for each log file separately.

Who does agree with me in that issue?

Kind regards,
Gerald

BTW: I created an issue on Github https://github.com/joomla/joomla-cms/issues/34735.

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 24985
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, Netherlands
Contact:

Re: Anonymize client IP addresses in Joomla log files - how?

Post by pe7er » Thu Jul 08, 2021 10:27 am

gba wrote:
Thu Jul 08, 2021 9:22 am
BTW: I created an issue on Github https://github.com/joomla/joomla-cms/issues/34735.
Great!

If someone creates some code to make it configurable, and it will be added to the Joomla core, then it will only be for Joomla 4.x. There won't be new features added to Joomla 3.

Another option to change Joomla's behavior is with plugins.
I guess that it's possible to write a plugin that removes that information before it is stored.
Or removes it afterwards from the database table.
Kind Regards,
Peter Martin, Global Moderator
Company website: https://db8.nl/en/ - Joomla specialist, Nijmegen, Netherlands
The best website: https://the-best-website.com

gba
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 117
Joined: Tue Jun 03, 2014 3:37 pm

Re: Anonymize client IP addresses in Joomla log files - how?

Post by gba » Thu Jul 08, 2021 12:30 pm

Here is my code:

Code: Select all

JLog::addLogger(
	array(
		'text_file' => 'my.php',
		'text_entry_format' => '{DATE}|{TIME}|{CLIENTIP}|{PRIORITY}|{MESSAGE}'
	),
	JLog::ALL,
	array('myarray')
);

$entry = new Joomla\CMS\Log\LogEntry('mytext', JLog::ERROR, 'myarray');
$entry->clientIP = substr(Joomla\Utilities\IpHelper::getIp(),0,-2).'**';
JLog::add($entry);

gba
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 117
Joined: Tue Jun 03, 2014 3:37 pm

Re: Anonymize client IP addresses in Joomla log files - how?

Post by gba » Wed Sep 15, 2021 3:13 pm

gba wrote:
Thu Jul 08, 2021 12:30 pm
Here is my code:

Code: Select all

JLog::addLogger(
	array(
		'text_file' => 'my.php',
		'text_entry_format' => '{DATE}|{TIME}|{CLIENTIP}|{PRIORITY}|{MESSAGE}'
	),
	JLog::ALL,
	array('myarray')
);

$entry = new Joomla\CMS\Log\LogEntry('mytext', JLog::ERROR, 'myarray');
$entry->clientIP = substr(Joomla\Utilities\IpHelper::getIp(),0,-2).'**';
JLog::add($entry);
Is that of help for you?


Locked

Return to “Administration Joomla! 3.x”