I'm writing two plugins at the moment which need to (optionally) log stuff...lots of stuff...somewhere. Since i don't like the 'you need to have proper permissions in this and that folder' messages of some plugins, ideally, i'd like to do it in the database.

But before i start creating my own db tables (which is also something i don't like for plugins to be doing), i'm wondering if WordPress has anything that could help with suchalike enterprise hidden in the dark deep of its codebase catacombs?



4 Answers 4


Wordpress makes use of the reliable PHP error logging. It provides an API of it's own and it's fully documented here: Error Handling and Logging and often it's already well integrated into server configurations.

For optional logging you can just use trigger_error() with it's default error-type notice (E_USER_NOTICE).

Doing so will ensure you're streamlined with wordpress error reporting and logging.

Wordpress, does not have a logging API or something that does even close to that burried down deep in it's spaghetti code. You can however make use of existing PHP based solutions that do provide high-level logging functionality like Apache Log4php which supports logging into different storages, incl. databases.

  • I'm afraid that isn't quite what i'm looking for...it's good for debug logging, yes...but what i want to log is not error or debug data. It's in one case emails the system sends out, in the other external calls to an API script, namely calls from PayPal to an IPN handler.
    – wyrfel
    Commented Feb 23, 2011 at 9:32
  • +1 though, because your answer still helps me with debug logging
    – wyrfel
    Commented Feb 23, 2011 at 9:34
  • wyrfel: suit yourself: logging.apache.org/log4php - I think this ships with pretty much you need.
    – hakre
    Commented Feb 23, 2011 at 10:51
  • @hakre: It's not completely true that WordPress does not contain any logging API at all. The XML-RPC file has a very basic logging function, but it's hard to enable the global variable for it.
    – Jan Fabry
    Commented Feb 23, 2011 at 11:17
  • Thanks everyone, i decided to write my own generic logging plugin. It's coming along quite nicely...one just does a $this->logger = new Logger('my_logger', 'My Logger') within one's 'init' callback and can then do $this->logger->log('my_log_tag', 'My Log Message', array('my' => 'log', 'entry' => 'data'));. When in Admin the same instanciation call also causes the logger to register itself, which subsequently results in a submenu being created for it under the new 'Logs' menu. Will take a little while before release, though.
    – wyrfel
    Commented Feb 23, 2011 at 13:54

I created my own plugin and it's now available from in the repository.

(Edit: The plugin moved to its new home under the right name, so packaging and auto-update should be fine.)

  • Thanks for the plugin! This is perfect for a project I'm working on (where clients need quick access to basic event logs), and it's saving me a ton of work. I had a bit of trouble getting the plugin going though, and I tracked it down to what I think is an incorrect usage of PHP's compact function in the actual log method. You're doing something like compact($myvar), when it should be compact('myvar'). Compact will accept a var instead of a string, but only when the var is an array containing strings. Anyway, just FYI. Cool plugin!
    – MathSmath
    Commented Apr 4, 2011 at 22:27

You can just use a hidden custom post type, like this plugin here:

http://wordpress.org/extend/plugins/log-deprecated-notices (It's written by core developer Nacin).

  • I think that's a BAD idea. It will spam your posts and potentially postmeta tables with lots of records making your whole system slower and slower pretty quickly. The only advantage i see in this is the ease of hooking into the taxation framework and the admin UI, but that doesn't really justify it.
    – wyrfel
    Commented Feb 23, 2011 at 13:48
  • I think you mean taxonomy framework. We're not taxing anybody. :)
    – scribu
    Commented Feb 23, 2011 at 16:23
  • @scribu LOL...indeed!
    – wyrfel
    Commented Feb 26, 2011 at 3:59
  • @scribu: andrew's approach looks really nice to me, could you comment on whether you think @wyrfel has a valid concern? would logging 10s of 1000s of actions, thereby creating huge numbers of posts, potentially slow things down? (i'm making the assumption that those log posts are not viewable on the front end to normal visitors, they'd just be sitting in the wp_posts table and only occasionally viewed by the admin user.) Commented Feb 28, 2011 at 15:22
  • Well, I've worked on installs with 300.000+ actual posts without problems. So it's mostly a matter of perception over the value of those logs.
    – scribu
    Commented Feb 28, 2011 at 16:38

I have just discovered Wordpress Logging Service plugin. Screenshots looks promising, looks maintained and it's at least past version 1.0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.