Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9206595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:12:33+00:00 2026-06-18T00:12:33+00:00

I am following the cakephp documentation to implement the database logger function. I got

  • 0

I am following the cakephp documentation to implement the database logger function. I got everything working after creating the logger class in

app/Lib/Log/Engine/DatabaseLogger.php 

and add these lines to bootstrap

CakeLog::config('otherFile', array(
'engine' => 'DatabaseLogger',
'model' => 'LogEntry',
// ...
));

After this I can log to the database by calling

CakeLog::info(message);

Everything works fine, but then I ran into problem trying to automatically log the user’s username and ip address. I have searched for many solutions onlien but I do not seems to be able to find an answer. Is it possible to access the controller in the DatabaseLogger class?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:12:34+00:00Added an answer on June 18, 2026 at 12:12 am

    You don’t need access to the controller

    The information you need is effectively global, you don’t need to access the controller object to get it.

    Client IP

    You can use the Router::getRequest method to get the current request object and retrieve the client IP from that:

    $request = Router::getRequest();
    $ip = $request->clientIp();
    

    Or simply use the env method:

    $ip = env('REMOTE_ADDR');
    

    Current User’s name

    For this, just use the static session interface:

    $name = CakeSession::read('Auth.User.name');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm following this tutorial for creating automated sitemaps in CakePHP. Everything is easy, but
I've been working in CakePHP and I got the following problem. I have a
I've got a CAKEPHP app which has the following rewrite rules in the .htaccess
Following the intro cakephp tutorial to create a blog, I created a database to
I'm using CakePHP 2.1 I have following fields in database. id views max_views I
I have an issue with using the following code in my CakePHP app. In
CakePHP APP folder contains following folders: - config - controllers - libs - locale
Using CakePHP 1.3, I have the following layout: /srv/www/_cakephp13/ /app/ /cake/ /plugins/ /vendors/ etc...
In the behaviors section of CakePHP documentation the following statement can be found: Since
I have the following form in cakephp: <div class=quickcontactDisplay> <?php echo $form->create('Enquiry',array('action'=>'add','class'=>'quickcontact')); echo $form->hidden('visitor_id',

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.